Hello! I have a ListView with let's say 5 items. When I click on one of these it automatically start a new activity based on the position of my ListView.
Then, in the new activity, it shows like "1 of 5".
I have two buttons (back and next) to show 2 of 5 etc, but how should I implement so it loads new content without starting a lot of activites for every "2 of 5", "3 of 5" etc..? It's meant to be done this way so the user don't need to go back to the ListView and then choose the second position..
My current code (From the ListView):
OnItemClickListener itemListener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long rowid) {
Intent intent = new Intent().setClass(ctx, Details.class);
Bundle b = new Bundle();
b.putInt("id", parent.getPositionForView(v));
intent.putExtras(b);
startActivity(intent);
}
};
and then a piece of code in Details.java:
next = (Button)findViewById(R.id.next_button);
back = (Button)findViewById(R.id.back_button);
Bundle b = getIntent().getExtras();
id = b.getInt("id");
id_header_sum = id+1;
String string_id = Integer.toString(id_header_sum);
one_of_all.setText(string_id + " of 5");
nextOnClick = new OnClickListener() {
public void onClick(View arg0) {
if(id_header_sum==30){
}
else {
}
}
};
backOnClick = new OnClickListener() {
public void onClick(View arg0) {
if(id_header_sum==1){
}
else {
}
}
};
next.setOnClickListener(nextOnClick);
back.setOnClickListener(backOnClick);
I don't want to start a single activity for every detail.
Please tell me if the question is unclear and thanks in advance!