i checked previous answers and documents about this topic but i can't adapt it to my situation. I have two arraylists full of my special classes objects. I have two different type of rows in xml. I want to create two different rows and fill each of it with related arraylists items in my Adapter Class. Rough code:
public class KanalAdapter extends BaseAdapter {
Context context;
ArrayList<OfficialKanal> officialKanals;
ArrayList<NormalKanal> normalKanals;
LayoutInflater lala;
public KanalAdapter(Context context , ArrayList<OfficialKanal> officiallar, ArrayList<NormalKanal> normaller){
this.context = context;
officialKanals = officiallar;
Log.i("tago" , "tagtag");
normalKanals = normaller;
lala = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return normalKanals.size()+officialKanals.size();
}
public Object getItem(int i) {
return ??
}
public long getItemId(int i) {
return ??
}
@Override
public int getItemViewType(int position) {
return ??
}
@Override
public int getViewTypeCount() {
return 2;
}
public View getView(int position, View convertView, ViewGroup viewGroup) {
KanalHolder holder;
int type = getItemViewType(position);
if(convertView==null){
holder = new KanalHolder();
switch (type){
case 0:
convertView = lala.inflate(R.layout.normalkanal,null);
holder.image1 = (ImageView) convertView.findViewById(R.id.imageView5);
holder.tv1 = (TextView) convertView.findViewById(R.id.textView4);
Log.i("tago", "tagtagtag");
holder.tv2 = (TextView) convertView.findViewById(R.id.textView8);
holder.buton1=(Button) convertView.findViewById(R.id.button8);
break;
case 1:
break;
}
convertView.setTag(holder);
}else{
holder = (KanalHolder)convertView.getTag();
}
holder.tv1.setText(normalKanals.get(position).getKanaladi());
holder.image1.setImageResource(R.mipmap.aliprof);
return convertView;
}
static class KanalHolder{
public ImageView image1;
public TextView tv1 , tv2;
public Button buton1;
}
I can handle getView part someway but how should i use other methods ??