Android Contextmenu Option With Icon
Hi All I have a simple question - It is possible to add a menu item with an icon to a context menu ? I've searched this issue and all I found is that it is not possible, but in the
Solution 1:
Wherever you see icons, that's not a context menu. If it feels a bit like a context menu but has icons, that's probably an AlertDialog
with a custom ListAdapter
that uses rows with icons.
Solution 2:
you need to expand your adapter
publicclassMenu_adapterextendsBaseAdapter {
and the method
public View getView(int position, View convertView, ViewGroup parent) {
Menu_itemmenu_item= (Menu_item) this.getItem(position);
ViewHolder viewHolder;
if (convertView == null) {
convertView = lInflater.inflate(R.layout.item_left_elements, null);
viewHolder = newViewHolder();
viewHolder.text = (TextView) convertView
.findViewById(R.id.tvDescr);
convertView.setTag(viewHolder);
convertView.setTag(R.id.tvDescr, viewHolder.text);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
ImageViewimageView= (ImageView) convertView.findViewById(R.id.ivImage);
if (menu_item.get_Item_Use() == true ) {
imageView.setImageResource(R.drawable.ic_menu_arrow_icon_pressed);
} else {
imageView.setImageResource(R.drawable.ic_menu_arrow_icon);
}
viewHolder.text.setTag(position);
viewHolder.text.setText(res.getString(menu_item.get_Item_id()));
return convertView;
}
Post a Comment for "Android Contextmenu Option With Icon"