title: Input dialog doesn't take right value ,
body: <p>I'm trying to make a spreadsheat, but I face a problem - I get a "reandom" result returned by the dialog box.</p>
  
  <p>my XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:background="#FFFFFF"
  android:orientation="vertical"&gt;
  
  
    &lt;TableLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginHorizontal="10dp"
      android:layout_marginVertical="30dp"
      android:background="#FFFFFF"&gt;
  
   &lt;TableRow
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="#020202"
      android:layout_marginHorizontal="1dp"
      android:layout_marginVertical="0dp"&gt;
  
      &lt;TextView
          android:id="@+id/titleR"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:gravity="center"
          android:text="prod price"
          android:background="@android:color/white"
          android:layout_marginHorizontal="1dp"
          android:layout_marginVertical="1dp"/&gt;
  
      &lt;TextView
          android:id="@+id/titleQ"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:gravity="center"
          android:text="Quantité"
          android:background="@android:color/white"
          android:layout_marginHorizontal="0dp"
          android:layout_marginVertical="1dp"/&gt;
  
      &lt;TextView
          android:id="@+id/titleT"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:gravity="center"
          android:text="Totale"
          android:background="@android:color/white"
          android:layout_marginHorizontal="1dp"
          android:layout_marginVertical="1dp"/&gt;
      &lt;/TableRow&gt;
  
      &lt;TableRow
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginHorizontal="1dp"
      android:layout_marginVertical="0dp"
      android:background="#020202"
      android:baselineAligned="false"
  
      &gt;
  
      &lt;TextView
          android:id="@+id/r5"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_marginHorizontal="1dp"
          android:layout_weight="1"
          android:background="@android:color/white"
          android:gravity="center"
          android:text="v 5 usd"
  
          /&gt;
  
      &lt;EditText
          android:id="@+id/q5"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_marginHorizontal="0dp"
          android:layout_marginVertical="0dp"
          android:layout_weight="1"
          android:background="@android:color/white"
          android:gravity="center"
          android:inputType="numberDecimal"
          android:maxLength="5"
          android:maxLines="1"
          android:text="0"
  
          /&gt;
  
      &lt;TextView
          android:id="@+id/t5"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_marginHorizontal="1dp"
          android:layout_marginVertical="0dp"
          android:layout_weight="1"
          android:background="@android:color/white"
          android:gravity="center"
          android:text=""/&gt;
      &lt;/TableRow&gt;
       &lt;TableRow
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_marginHorizontal="1dp"
       android:layout_marginVertical="0dp"
       android:background="#020202"
  
       &gt;
       &lt;TextView
           android:layout_marginTop="1dp"
           android:id="@+id/myprc"
           android:layout_width="wrap_content"
           android:layout_height="match_parent"
           android:layout_weight="1"
           android:background="@android:color/white"
           android:layout_marginBottom="1dp"
           android:layout_marginHorizontal="1dp"
           android:text="Pourcentage"
           android:gravity="center"
           android:onClick="onClick"
           &gt;&lt;/TextView&gt;
  
       &lt;TextView
           android:layout_marginTop="1dp"
           android:id="@+id/prcc"
           android:layout_width="wrap_content"
           android:layout_height="match_parent"
           android:layout_marginHorizontal="0dp"
           android:layout_marginBottom="1dp"
           android:layout_weight="1"
           android:autoText="false"
           android:background="@android:color/white"
           android:clickable="true"
           android:gravity="center"
           android:inputType="text"
           android:maxLength="2"
           android:maxLines="1"
           android:text="6%"&gt;&lt;/TextView&gt;
       &gt;&lt;TextView
       android:layout_marginTop="1dp"
       android:id="@+id/prcT"
       android:layout_width="wrap_content"
       android:layout_height="25dp"
       android:layout_weight="1"
       android:background="@android:color/white"
       android:layout_marginBottom="1dp"
       android:layout_marginHorizontal="1dp"
       &gt;&lt;/TextView&gt;
      &lt;/TableRow&gt;
  
   &lt;/TableLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>my java code:</p>
  
  <pre><code>package com.example.mcalc;
  
  import androidx.appcompat.app.AlertDialog;
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.content.DialogInterface;
  import android.os.Bundle;
  import android.text.Editable;
  import android.text.TextWatcher;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  
  
  import org.w3c.dom.Text;
  
  import java.text.DecimalFormat;
  
  
  public class MainActivity extends AppCompatActivity {
      TextView myprc;
      EditText q5;
      TextView t5;
      TextView t50;
      TextView prcc;// cel
      TextView prcT;
      double prc1;
      DecimalFormat tst = new DecimalFormat(" #,0.00 '%'");
      EditText input;// dilog input
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.tabble);
  
          myprc = (TextView)findViewById(R.id.myprc);
          q5 = (EditText) findViewById(R.id.q5);
          t5 = (TextView) findViewById(R.id.t5);
          t50 = (TextView) findViewById(R.id.t50);
          prcc = (TextView) findViewById(R.id.prcc) ;//cel
          prcT = (TextView) findViewById(R.id.prcT);
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder.setTitle("Pourcentage");
          builder.setMessage("Merci d entrer le %");
          input=new EditText(this);
          builder.setView(input);
  
          ////
          builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  prc1 = Double.parseDouble(input.getText().toString());
                  String str;
                  str= String.valueOf(((Double) prc1));
                  prcc.setText(str+"%");
              }
          });
  
          final   AlertDialog ad = builder.create();
          //Click listener Pourcentage %
          myprc.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  ad.show();
              }
          });
  
          q5.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence s, int start, int count, int after) {
              }
  
              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {
                  double tq5;
  
                  if ((q5.getText().length() == 0)) {
                      t5.setText("");
                  } else {
                      tq5 = (Double.valueOf(q5.getText().toString())*5) - 
                            (Double.valueOf(q5.getText().toString())*5*prc1);
                      t5.setText(""+tq5);
                  }
  
  
              }
  
              @Override
              public void afterTextChanged(Editable s) {
              }
          });
          prcc.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence s, int start, int count, int after) {
              }
  
              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {
                  double prc;
  
                  if ((prcc.getText().length() == 0)) {
                      prcT.setText("");
                  } else {
                      prcT.setText("blabla");
                  }
              }
              @Override
              public void afterTextChanged(Editable s) {
              }
          });
      }
  }
  </code></pre>