You need to move this code
final EditText et = (EditText) findViewById(R.id.editText1);
Button getAnswer = (Button) findViewById(R.id.button1);
getAnswer.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (et.getText().toString().length()==0) {
Toast.makeText(getApplicationContext(),"Can't Be Blank!",Toast.LENGTH_LONG).show();
}else{
EditText et = (EditText) findViewById(R.id.editText1);
String searchTerm = et.getText().toString().trim();
Intent in = new Intent(MainActivity.this, ListView.class);
in.putExtra("TAG_SEARCH", searchTerm);
startActivity(in);
}
}
});
}
out of the if
part of your code. As Shobhit is saying, this is never getting run the next time you run your app. It only runs if installed
is false
which is never true after the first run.
Edit-Avoid window leak errors with the Dialog
You can always check if the Dialog
is open with dialog.isShowing()
and close the Dialog if returns true before the Activity is destroyed or something (another Activity
) comes on top. You can do this in onPause().
@Override
public void onPause()
{
if (dialog != null && dialog.isShowing())
{
dialog.dismiss();
super.onPause();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…