我已经实现了操作栏按钮的代码并且它工作正常但在此之后我的智能手机后退按钮关闭或在我按下它时最小化。这是我的代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
/**
* Action Bar Back Button
*/
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
moveTaskToBack(true);
AboutActivity.this.finish();
}
答案 0 :(得分:1)
public void onBackPressed() {
moveTaskToBack(true);
AboutActivity.this.finish();// you are finishing the activity
}
如果你想回去试试这个
@Override
public void onBackPressed()
{
// code here to show dialog
super.onBackPressed(); // optional depending on your needs
}