Application crashes

  • Replies:3
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Nov 21, 2015 5:09:12 AM via Website

This is my code below it complies properly and when i click on the calculate button the app crashes i dont understand y?????

package thumbplay.tip;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class tip extends Activity {

double tbill;
double tippercent;
double tip_cal;
protected void onCreate(Bundle savedInstanceState) {
    final EditText billamt = (EditText) findViewById(;

// final EditText tip=(EditText)findViewById(;
final EditText tip_percent = (EditText) findViewById(;
final TextView totalbill = (TextView) findViewById(;
//final TextView tipamount=(TextView)findViewById(;
//final TextView hpays=(TextView)findViewById(;
final Button calculate = (Button) findViewById(;

    calculate.setOnClickListener(new OnClickListener() {
                                     public void onClick(View v) {
                                          tbill = Double.parseDouble(billamt.toString());
                                         tippercent = Double.parseDouble(tip_percent.toString());
                                         tip_cal = (tbill * tippercent) / 100;


  • Forum posts: 19

Dec 6, 2015 11:30:01 AM via Website

To get the edittext's value, use edittext.getText().toString. In your case e.g.

instead of billamt.toString()
use billamt.getText().toString()
and so on.
And make use of the Log command to find out where you app crashes.