国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android中ActionBar和ToolBar添加返回箭頭的實(shí)例代碼

2019-12-12 02:03:46
字體:
供稿:網(wǎng)友

 1.ActionBar添加返回箭頭

//onCreate方法中ActionBar actionBar = this.getSupportActionBar();actionBar.setTitle("搜索功能");actionBar.setDisplayHomeAsUpEnabled(true);//activity類中的方法@Override  public boolean onOptionsItemSelected(MenuItem item) {    if(item.getItemId() == android.R.id.home)    {      finish();      return true;    }    return super.onOptionsItemSelected(item);  }

在這里,ActionBar引入包:import android.support.v7.app.ActionBar;

2. ToolBar添加返回箭頭

代碼如下:

//onCreate函數(shù)中Toolbar mToolbarTb = (Toolbar) findViewById(R.id.toolbar);setSupportActionBar(mToolbarTb);getSupportActionBar().setDisplayHomeAsUpEnabled(true);//activity類中的方法//添加點(diǎn)擊返回箭頭事件@Overridepublic boolean onOptionsItemSelected(MenuItem item) {  if(item.getItemId() == android.R.id.home)  {    finish();    return true;  }  return super.onOptionsItemSelected(item);}

總結(jié)

以上所述是小編給大家介紹的Android中ActionBar和ToolBar添加返回箭頭的實(shí)例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 嘉禾县| 图片| 江都市| 栾川县| 阆中市| 凌源市| 新巴尔虎左旗| 常州市| 台东市| 上饶县| 陆良县| 信阳市| 石楼县| 竹山县| 汝城县| 安阳市| 正镶白旗| 大新县| 凤凰县| 兴隆县| 潍坊市| 通道| 荆门市| 卢龙县| 大田县| 武定县| 阿图什市| 梧州市| 宜君县| 丰镇市| 崇义县| 如皋市| 灵寿县| 玉田县| 石阡县| 金寨县| 石狮市| 老河口市| 昌邑市| 灵璧县| 昆山市|