Scenario : I have n number of tabs each tab is having its own listview. I am using a Array adapter to generate a listview. The array which is passed to arrayadaper is having array of objects. Each object has a "menu" and "menu type" . Now based on the menu type, if the menu type is "menugroup" i will draw using a different layout and set the background to RED colour.
Question is simple.. Whenever click is made on menugroup row in listview Nothing should happen. In other words, How to ignore the click made in the menugroup row. This is need to capture only the details of clicks made in menu row at onItemClick method. Could you please point me any idea/clue to proceed ? Thanks in advance.
public class MyCustomAdapter extends ArrayAdapter<Menu> {
private ArrayList<Menu> menuItemList;
Context context;
LayoutInflater vi;
public MyCustomAdapter(Context context ,ArrayList<Menu> menu) {
super(context, 0, menu );
this.menuItemList = new ArrayList<Menu>();
this.menuItemList.addAll(menu);
this.context =context;
vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
private class ViewHolder {
TextView menuItem;
TextView menuGroup;
}
public int getItemViewType(int position) {
if (menuItemList.get(position).getMenuType().equals("menugroup"))
return 0;
return 1;
}
public int getViewTypeCount() {
return 2;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
int type = getItemViewType(position);
if (convertView == null) {
holder = new ViewHolder();
switch (type) {
case 0:
convertView = vi.inflate(R.layout.group, null);
holder.menuItem = (TextView) convertView.findViewById(R.id.tvGroup);
convertView.setBackgroundColor(Color.RED);
break;
case 1:
convertView = vi.inflate(R.layout.item, null);
holder.menuItem = (TextView) convertView.findViewById(R.id.tvItem);
break;
}
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
switch (type) {
case 0:
holder.menuItem.setText(menuItemList.get(position).getItemName()) ;
convertView.setBackgroundColor(Color.RED);
break;
case 1:
holder.menuItem.setText(menuItemList.get(position).getItemName()) ;
break;
}
return convertView;
}
}