Reputation: 65
I want to have many Activities
that When I Clicked on a Item
of a ListView
starts an Activity
!
I think should use Array of Activities
to get reference to them! But How can I do that?
I want some thing like this
Activity[] act=new Activity[100];
for(int i=0;i<100;i++){
act[i]=activity+i;/// my means here
}
list.setOnItemClickListener(new AdapterView.onItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View view, int position, long arg) {
Intent intent= new Intent(this, act[position].class);
startActivity(appInfo);
}
});
Upvotes: 0
Views: 68
Reputation: 3191
Try this:
Map<Integer,Object> activityMap;
onCreate()
...
activityMap = new HashMap<Integer, Object>();
Then iterate through your activity list and do:
activityMap.put(position,YourActivityclass);
And then onItemClickListener(), do :
Intent i = new Intent(thisActivity.this, activityMap.get(position);
Where position is the variable from onItemClickListener.
See if it helps !
Upvotes: 1