完全にカスタムのオーバーフロー メニュー項目を作成する必要があります (画像に表示されている最小限の異なる背景色)。
出来ますか?
完全にカスタムのオーバーフロー メニュー項目を作成する必要があります (画像に表示されている最小限の異なる背景色)。
出来ますか?
昨日、アクションバーシャーロックを実装する必要があります。私の場合はあなたの場合と同じでした。ナビゲーションリストにアダプタを実装しました。
public class MyNavigationAdapter extends BaseAdapter {
Context mContext = null;
String[] mTitles;
LayoutInflater mLayOutInflater = null;
public MyNavigationAdapter(Context context, String[] titles) {
this.mContext = context;
this.mTitles = titles;
mLayOutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return mTitles.length;
}
@Override
public Object getItem(int arg0) {
return null;
}
@Override
public long getItemId(int arg0) {
return 0;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
if (view == null)
view = mLayOutInflater.inflate(R.layout.my_list_custom_row, parent,false);
TextView rowName = (TextView) view.findViewById(R.id.title);
rowName.setText(mTitles[position]);
rowName.setBackground(your desire drawle);// yo
u can also set color etc.
//OR
if(position%2==0)
rowName.setBackgroundColor(Color.RED);
else
rowName.setBackgroundColor(Color.BLUE);
return view;
}
}
この後、ActivityonCreatemethosにこれらのコード行を記述する必要があります。
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setListNavigationCallbacks(mNavigationAdapterObj, mNavigationListner);
詳細については、こちらをご覧ください。
MenuItem ごとにカスタム ビューを設定できます。
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("test").setActionView(R.layout.custom_action_menu_item);
return super.onCreateOptionsMenu(menu);
}
http://developer.android.com/reference/android/view/MenuItem.html#setActionView%28int%29
これhttps://stackoverflow.com/a/14123377/2069363は私のために働きます!
メニュー項目のアクション レイアウトで Spinner (または ActionBarSherlock の IcsSpinner) を使用して、このような動作を作成できます。ちょっとしたトリックを使用する必要がありますが、現在選択されているアイテムを非表示にします。