0
我正在使用帶有微調器(下拉式)的ActionBar,但事情是選擇區域本身上的文本不應該是列表中的元素之一。此外,我使用自定義適配器來定製微調器中的元素,該自定義適配器還自定義選擇區域。微調器下拉式自定義
可能是截圖是最好的。這是我想達到什麼:
這是我目前有:
從我的自定義適配器片段:
public class CategoriesDropDownAdapter extends BaseAdapter{
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.categories_drop_down_item, parent, false);
}
Category category = getCategory(position);
ImageView icon = (ImageView) convertView.findViewById(R.id.catIcon);
TextView title = (TextView) convertView.findViewById(R.id.catTitle);
//setting icon, title and background color
icon.setImageDrawable(category.getIcon());
title.setText(category.getTitle());
convertView.setBackgroundColor(category.getBackgroundColor());
//setting the width of the drop-down to take all the layout width
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics metrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(metrics);
convertView.setLayoutParams(new LayoutParams(metrics.widthPixels, 100));
return convertView;
}
}
如何避免自定義選擇區域(酒吧本身的區域)使用自定義適配器時?我希望對該區域進行不同的定製(例如,在右下角沒有那個三角形)。
如何,如果我的微調/動作條未在XML但在描述它做碼? actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(new CategoriesDropDownAdapter(...),this); – Haji 2014-09-02 10:53:37