Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to initialize Your button addtotal1:</p> <pre><code> addtotal1 = (Button)findViewById(R.id.yourButtonId); </code></pre> <p>before You could set onClickListener.</p> <h2>EDIT</h2> <p>Your xml EditText has only the inputType "number", so the user can´t put some decimal values. If You want it like this, You don´t need double variables. Instead of double, use int, so Your result is without showing decimal point:</p> <pre><code> public class durood extends Activity{ private TextView txtCount; private TextView totalCount; private EditText enteramount; private Button btnCount; private Button addtotal1; private Button addtotal2; private Button cleartotal; private static int count=0; private int x=0; private int y=0; private int z=0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // The activity is being created. setContentView(R.layout.durood); enteramount = (EditText)findViewById(R.id.enteramount); totalCount = (TextView)findViewById(R.id.totalCount); addtotal1=(Button)findViewById(R.id.addtototal1); addtotal2=(Button)findViewById(R.id.addtototal2); //add to total 1 addtotal1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { x=Integer.parseInt(enteramount.getText().toString()); y=Integer.parseInt(totalCount.getText().toString()); z=x+y; totalCount.setText(Integer.toString(z)); //to set value of enteramount to 0 enteramount.setText("0"); //or enteramaount.setText("") if You want show nothing } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload