更新时间:2022-02-02 05:16:03
add
toString()
if (keywords.getText().toString().equals("")){
Intent intent = new Intent(v.getContext(), Second.class);
startActivity(intent);
}else if(keywords.getText().toString().equals("a")){
Intent intent = new Intent(v.getContext(), Thrid.class);
startActivity(intent);
你好。起初我建议调试你的项目。它可以帮助您找到问题,但如果您不想这样做,您可以使用这段代码向您展示如何行动。
java code:
hello . at first i would suggest debugging your project. it helps you to find your problem but if you dont want to do it you can use this piece of code which shows you how to act .
java code :
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void method1(View v){
String Word="a";
String etValue="";
EditText et=(EditText)findViewById(R.id.et1);
etValue=et.getText().toString();
if(etValue.equals("a")){
// here you can do any action you want to do
// in your case you have to use intents
Toast.makeText(this, "it works fine", Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(this, "insert the correct word ! ", Toast.LENGTH_LONG).show();
}
}
}