幫助我在操作欄頂部顯示Actionbar菜單項。沒有顯示溢出下降menulist.kindly給我一個建議這樣做?如何在PreferenceActivity頂部顯示Actionbar菜單項?
0
A
回答
0
使用此在您的活動
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
LayoutParams lp = new LayoutParams(
android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT
| Gravity.CENTER_VERTICAL);
View customNav = LayoutInflater.from(this).inflate(R.layout.img, null);
EditText et = (EditText) customNav.findViewById(R.id.et);
temppaths = new ArrayList<String>();
Button iv = (Button) customNav.findViewById(R.id.iv);
iv.setClickable(true);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
});
actionBar.setCustomView(customNav, lp);
actionBar.setDisplayShowCustomEnabled(true);
和xmlLayout命名img.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:gravity="right" >
<EditText android:id="@+id/et"
android:layout_width="250dp"
android:layout_height="match_parent"
android:layout_marginRight="20dp"
android:gravity="center"
android:layout_gravity="right"
android:hint="[email protected], 1800xxxxx"
android:background="#FF8000" />
<Button
android:id="@+id/iv"
android:layout_gravity="right"
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_marginRight="20dp"
android:text="Search"
android:background="#FF8000" />
</LinearLayout >
+0
我希望顯示在首選項Activity.It必須在onCreateOption(),onOptionItemSelected()內完成。 –
+0
我不明白你試圖做 – raj
+0
Mr.raj你調用menuItem.Clearly理解的問題,我需要做的菜單項上的其他行動,我如何實現。我需要註銷,當我退出的方式人。 –
0
OKK然後
在你的活動添加這些方法
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, 0, 0, "LogOut").setShortcut('0', 'o')
.setIcon(android.R.drawable.ic_menu_edit);
menu.add(0, 1, 0, "Save").setShortcut('1', 's')
.setIcon(android.R.drawable.ic_menu_save);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 0:
Toast.makeText(getApplicationContext(), "Log out clicked", 0).show();
// save();
// showNewOrOpenDialog();
break;
case 1:
Toast.makeText(getApplicationContext(), "Save", 0).show();
// save();
break;
}
return false;
}
相關問題
- 1. 選項菜單不顯示在ActionBar
- 2. 如何設置背景菜單項顯示在actionBar
- 3. 在Magento 1.9如何在頂部菜單中顯示迷你車?
- 4. Android ActionbarSherlock顯示菜單按鈕頂部
- 5. ActionBar菜單出現在頂部和底部的2次
- 6. 如何顯示在窗口的標題欄的頂部菜單
- 7. actionbar菜單項onclick?
- 8. Android:RTL ActionBar菜單項
- 9. 如何在頁面底部顯示活動的頂層菜單子項?
- 10. 在「ActionBar」項目上顯示彈出式菜單點擊
- 11. Youtube Script API - 播放器顯示菜單項頂部
- 12. Android:如何在ActionBar中顯示圖標,但不在選項菜單中?
- 13. ActionBar菜單圖標只顯示在溢出菜單
- 14. 如何在ActionBar中顯示一些菜單文本?
- 15. 如何強制顯示圖標在actionBar菜單
- 16. 頂級菜單項顯示子菜單滑下
- 17. 如何顯示SonataAdminBundle中的頂部和側面菜單?
- 18. 如何在PreferenceActivity中使用ActionBar?
- 19. 在數據頂部和底部顯示SimplePager分頁菜單
- 20. ActionBar Sherlock菜單項OnClick
- 21. FragmentStatePageAdapter重複ActionBar菜單項
- 22. Actionbar子菜單項背景
- 23. 混淆ActionBar代碼不顯示菜單項
- 24. 顯示菜單項
- 25. 選項顯示在菜單
- 26. 如何模仿ActionBar菜單?
- 27. Google網站:點擊頂部菜單並在側欄上顯示子菜單
- 28. ActionBar(Sherlock)在頂部顯示帶有消息數量的圖標
- 29. DialogFragment出現在ActionBar頂部
- 30. 如何顯示部分菜單樹?
在菜單xml中使用showAsAction屬性.. – Kanika
我嘗試使用showAsAction,但它沒有顯示在頂部 –
我只有兩個菜單項在Menu.still其下拉溢出。 –