private ActionBar mActionBar;
mActionBar = getSupportActionBar();
mActionBar.setDisplayShowHomeEnabled(true); //顯示返回符號,在android 2.3測試,若setDis //playHomeAsUpEnabled沒寫,則無任何動作發生
mActionBar.setDisplayHomeAsUpEnabled(true); //不顯示返回符號,在onOptionsItemSelected須設定 //按下後動作
mActionBar.setTitle("Title ");
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// app icon in action bar clicked; goto parent activity.
onBackPressed();
return true;
...
}
}
-----------------------------------------
//可改寫返回鍵的內容設定
@Override
public void onBackPressed() {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("test", "i am come from Mainactivity2activity");
setResult(RESULT_OK, intent);
closeDB();
finish();
}
沒有留言:
張貼留言