У меня есть два вида layout.I хочу добавить их в ExpandableListView programming.I пытались setTag с ViewHolder. Но когда я пытался getTag, что всегда быть NullpointException. Вот мой код:Как добавить различные макеты в BaseAdapter?
SeekBarHolder sh=null;
TickHolder th=null;
if(convertView==null){
switch((Integer)childData.get(groupPosition).get(childPosition).get("type")){
case ProtocolConst.EXPANDABLE_CHILD_TYPE_SEEKBAR:
sh=new SeekBarHolder();
convertView=inflater.inflate(R.layout.fragment_left_listview_child_seekbar_item, null);
sh.text=(TextView)convertView.findViewById(R.id.Left_ExpandableListView_Child_SeekBar_TextView);
sh.seekbar=(SeekBar)convertView.findViewById(R.id.Left_ExpandableListView_Child_SeekBar_SeekBar);
convertView.setTag(sh);
case ProtocolConst.EXPANDABLE_CHILD_TYPE_TICK:
th=new TickHolder();
convertView=inflater.inflate(R.layout.fragment_left_listview_child_seekbar_item, null);
th.text=(TextView)convertView.findViewById(R.id.Left_ExpandableListView_Child_Tick_TextView);
th.tick=(ImageView)convertView.findViewById(R.id.Left_ExpandableListView_Child_Tick_ImageView);
convertView.setTag(th);
}}else{
switch((Integer)childData.get(groupPosition).get(childPosition).get("type")){
case ProtocolConst.EXPANDABLE_CHILD_TYPE_SEEKBAR:
sh=(SeekBarHolder)convertView.getTag();
break;
case ProtocolConst.EXPANDABLE_CHILD_TYPE_TICK:
th=(TickHolder)convertView.getTag();
break;
}
}