我有这个活动
import android.os.Bundle;
import android.util.Log;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
public class AboutActivity extends SherlockActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
getSupportActionBar().setIcon(R.drawable.logo);
getSupportActionBar().setDisplayOptions(0, getSupportActionBar().DISPLAY_SHOW_TITLE);
}
@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.layout.menu_back, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(
com.actionbarsherlock.view.MenuItem item) {
switch (item.getItemId()) {
case R.id.back:
AboutActivity.this.finish();
return true;
default:
return false;
}
}
}
这是我的 R.layout.menu_back
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/back"
android:icon="@drawable/arrow"
android:showAsAction="ifRoom|withText"
/>
</menu>
我的问题是,当我第一次单击菜单中的后退按钮时,它什么也没做,当我第二次单击它时它工作正常。有什么建议么?
谢谢