Currently, I have 3 arrays. I am trying for couple of hours. Can I implement this function in any dynamic way. For me For loop didn't work. is there any way to dynamically implement this. I will be glad , if you guys help to solve this.
switch(pageNumber){
case 0:
final ListView list1 = (ListView)rootView.findViewById(R.id.list);
BinderData bindingData = new BinderData(this.getActivity(), d[0]);
list1.setAdapter(bindingData);
list1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
if (d[0].get(position).getItemType() == 0
|| d[0].get(position).getItemType() == 3
|| d[0].get(position).getItemType() == 2)
return;
Intent intent = new Intent(Schedule.this.getActivity(),
ContentExtended.class);
intent.putExtra("title", d[0].get(position).getTitle());
intent.putExtra("content", d[0].get(position).getContent());
startActivity(intent);
}
});
break;
case 1:
final ListView list2 = (ListView)rootView.findViewById(R.id.list);
BinderData bindingData1 = new BinderData(this.getActivity(), d[1]);
list2.setAdapter(bindingData1);
list2.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
if (d[1].get(position).getItemType() == 0
|| d[1].get(position).getItemType() == 3
|| d[1].get(position).getItemType() == 2)
return;
Intent intent = new Intent(Schedule.this.getActivity(),
ContentExtended.class);
intent.putExtra("title", d[1].get(position).getTitle());
intent.putExtra("content", d[1].get(position).getContent());
startActivity(intent);
}
});
break;
case 2:
final ListView list3 = (ListView)rootView.findViewById(R.id.list);
BinderData bindingData2 = new BinderData(this.getActivity(), d[2]);
list3.setAdapter(bindingData2);
list3.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
if (d[2].get(position).getItemType() == 0
|| d[2].get(position).getItemType() == 3
|| d[2].get(position).getItemType() == 2)
return;
Intent intent = new Intent(Schedule.this.getActivity(),
ContentExtended.class);
intent.putExtra("title", d[2].get(position).getTitle());
intent.putExtra("content", d[2].get(position).getContent());
startActivity(intent);
}
});
break;
}