我的应用程序按钮没有';t work,handler.java错误
我创建了一个非常简单的测验应用程序,提交答案后应该给你祝贺的按钮根本不起作用。我看到handler.java文件中有很多错误,所以可能这就是问题所在,但我不知道该怎么办。(无法粘贴处理程序文件,因为它超出了post的限制)我的应用程序按钮没有';t work,handler.java错误,java,android,button,handler,Java,Android,Button,Handler,我创建了一个非常简单的测验应用程序,提交答案后应该给你祝贺的按钮根本不起作用。我看到handler.java文件中有很多错误,所以可能这就是问题所在,但我不知道该怎么办。(无法粘贴处理程序文件,因为它超出了post的限制) 正如Rohit5k2所建议的。。。试试这个: TextView intrebare = (TextView) findViewById(R.id.intrebare); Button buton = (Button) findViewById(R.id.button)
正如Rohit5k2所建议的。。。试试这个:
TextView intrebare = (TextView) findViewById(R.id.intrebare);
Button buton = (Button) findViewById(R.id.button);
final TextView rasplata = (TextView) findViewById(R.id.rasplata);
buton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final EditText raspuns = (EditText) findViewById(R.id.raspuns);
if (raspuns.getText().toString().equals("Bucuresti")) {
rasplata.setText("BRAVOO!!!");
}
}
});
非常适合我。正如Rohit5k2建议的那样。。。试试这个:
TextView intrebare = (TextView) findViewById(R.id.intrebare);
Button buton = (Button) findViewById(R.id.button);
final TextView rasplata = (TextView) findViewById(R.id.rasplata);
buton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final EditText raspuns = (EditText) findViewById(R.id.raspuns);
if (raspuns.getText().toString().equals("Bucuresti")) {
rasplata.setText("BRAVOO!!!");
}
}
});
对我来说很好。它在Logcat中说了什么?在
handler.java中有很多错误都没有帮助。但是在这个代码中,(raspuns.getText().toString()==“Bucuresti”
应该是(raspuns.getText().toString().equals(“Bucuresti”)
。或者“equalsIgnoreCase”,以防大写字母与否无关。它在Logcat中说了什么?在处理程序中有很多错误。java
没有帮助。但是在这个代码中(raspuns.getText().toString()==“Bucuresti”
应该是(raspuns.getText().toString().equals(“Bucuresti”)
)或者“equalsIgnoreCase”,以防大写字母与否无关。