我正在制作一个聊天应用程序,因此想要在我的actionbar()
聊天活动中添加图标以及后退按钮(就像它在WhatsApp的),但我不能同时设置的东西...如何在操作栏上插入图标以及后退按钮(如在whatsapp中)
这里是代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
initControls();
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
Intent intent = getIntent();
String itemname = intent.getStringExtra("itemname");
actionBar.setTitle(itemname);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
actionBar.setIcon(R.mipmap.ic_launcher);
}
的问题是,无论是东西没有得到设置在同一时间与上面的代码只返回按钮显示,如果我删除后退按钮的代码,然后图标显示了......如何设置这两个东西?
由于它的工作:) –
如何实现这个搜索栏??? –
充气菜单中的搜索图标应该在那里。在你的工具栏中添加一个searchview组件将其可见性设置为隐藏android:layout_width =“match_parent” android:layout_height =“wrap_content” android:id =“@ + id /搜索查看” 应用:iconifiedByDefault =‘假’ 应用:searchIcon =‘@空’ >' ,然后看法 – Ashwani