public class BaseActivity extends AppCompatActivity { //让返回键起作用 @Override public boolean onOptionsItemSelected(MenuItem item) { Log.i("info","执行BaseActivity中的onOptionsItemSelected"); if (android.R.id.home == item.getItemId()) { this.finish(); //关闭当前接口 return true; } return super.onOptionsItemSelected(item); } public void getActionBar(String title, AppCompatActivity activity) { // 设置标题栏返回键 ActionBar callbackBar = activity.getSupportActionBar(); if (callbackBar != null) { callbackBar.setDisplayHomeAsUpEnabled(true);//给左上角添加一个返回的箭头图标 callbackBar.setHomeButtonEnabled(true);//设置图标可以点击 callbackBar.setDisplayShowHomeEnabled(true);//使图标可以显示 callbackBar.setTitle(title); //标题设置 } } protected void showMessage(String message) { String title = Constant.appName;
android界面返回键与弹框的编写
最新推荐文章于 2024-08-21 15:46:58 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)