为什么我会收到此错误:" sonuc无法解决"?

时间:2015-10-30 15:50:52

标签: android

为什么我会收到此错误:" sonuc无法解决"?

public class MainActivity extends Activity {

    public void onCreate(Bundle ben)
    {
        super.onCreate(ben);
        setContentView(R.layout.activity_main);
        final TextView sanuc=(TextView)findViewById(R.id.sonuc);
        final EditText say1=(EditText) findViewById(R.id.sayi1);
        final EditText say2=(EditText) findViewById(R.id.sayi1);

        Button topla=(Button)findViewById(R.id.topla);

        topla.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              //at the this place I did parsed to integer           
               sonuc.setText(Integer.parseInt(say1.getText().toString()) 
                                   + Integer.parseInt(say2.getText().toString()));
            }
        });
    }
}

1 个答案:

答案 0 :(得分:2)

将sonuc.setText(...)更改为sanuc.setText(...)

xml id和java变量名称有不同的拼写。