Android studio : Generate a pdf with the data entered by a user – Java

  android, android-edittext, java, pdf, textview

I am new to computer programming.

I created an app on android studio with the Java language.
I would like that when I press the ImageButton a pdf would be generated and stored on the phone. This must include the content of the EditText entered by the user and the TextView in a table.

I am therefore looking for examples on the subject.

I put you my xlm:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/Quantity_percent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginRight="16dp"
        android:inputType="numberDecimal"
        android:textSize="12sp">


    </EditText>

    <EditText
        android:id="@+id/Quantity_gr"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginRight="16dp"
        android:hint="Quantité en gr."
        android:inputType="numberDecimal"
        android:textSize="12sp">

    </EditText>

    <EditText
        android:id="@+id/Total_quantity"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginRight="16dp"
        android:hint="Quantité totale"
        android:inputType="numberDecimal"
        android:textSize="12sp">

    </EditText>

    <TextView
        android:id="@+id/Result"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginRight="16dp"
        android:hint="Resultat"
        android:textSize="12sp">

    </TextView>

    <Button
        android:id="@+id/Calculate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginRight="16dp"
        android:hint="Calculer"
        android:text="Calcul"
        android:textSize="12sp">

    </Button>

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginRight="16dp"
        android:orientation="horizontal">

        <RadioButton
            android:id="@+id/Button_percent"
            android:layout_width="190dp"
            android:layout_height="match_parent"
            android:checked="false"
            android:onClick="onRadioButtonClicked"
            android:text="%" />

        <RadioButton
            android:id="@+id/Button_gr"
            android:layout_width="190dp"
            android:layout_height="match_parent"
            android:onClick="onRadioButtonClicked"
            android:text="Gr." />
    </RadioGroup>

    <TextView
        android:id="@+id/Message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <ImageButton
        android:id="@+id/imageButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:srcCompat="@android:drawable/ic_menu_share" />

</LinearLayout>

Can you help me ?

Thank you.

Source: Android Questions

LEAVE A COMMENT