如果文本框 = ""
nextActivity.show
else msg = "对不起!"
任何人都可以帮助并告诉我如何在 Android eclipse java 中制作这个吗?
我这里有一个代码,但我不知道如何更正。
private EditText inputtxt;
private Button btnNext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_g1);
inputtxt = (EditText) findViewById(R.id.editText1);
btnNext.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View ContentView) {
// TODO Auto-generated method stub
String name;
name=inputtxt.getText().toString();
if (name.contentEquals("Accounting"))
{
Intent myIntent = new Intent (ContentView.getContext(), NextActivity.class);
startActivityForResult(myIntent, 0);
}
else
{ Toast.makeText(getBaseContext(), "Sorry, wrong answer. Try Again!", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.g1, menu);
return true;
}
`