File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes ListView - next previous about another Activity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "ListView - next previous about another Activity" Watch "ListView - next previous about another Activity" New topic

ListView - next previous about another Activity

paul beppe
Ranch Hand

Joined: Aug 09, 2012
Posts: 86

i have 2 activity, in one activity i have listView and in another activity i want next and previous of ListView the fist activity...

Thi is code:

this is another activity where i want show row about buttons next and previous:

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

The first thing you should do is write up a very detailed specification about what you need to do. Then you need to consider the requirements for implementing the specification. Then you need to plan out the code to implement the specifications, give the requirements. Finally, when you have code and a problem, you can ask a specific question here.

What you seem to have done here is come up with an almost - specification. You probably know what you want, but you definitely didn't communicate it well, probably because you didn't flesh out all the details yourself. Then you posted code without attempting to implement the specification. So we can't really look at the code to see what your intent was. Also, since you didn't try to write the code, you aren't getting an error and don't have a specific question, so it makes getting an answer take longer. Part of the reason you don't have code is probably because you don't really know 'where to begin.' Knowing where to begin comes from understanding your specification, and coming up with the requirements to implement that specification. Since you are the one writing the app and have the concept, you need to come up with the specification, and from that you should be able to come up with the requirements (and from there, code to attempt to implement them).

For example, you said:
paul beppe wrote:i have 2 activity, in one activity i have listView and in another activity i want next and previous of ListView the fist activity...
I don't really know what that means, but if I were to take my first translation and turn it into a specification I might come with:
steve luke wrote:I have an ordered list of names. On one activity I plan on displaying those names as a scrollable list, such as you get with a ListView. In this first activity the user will be able to click on a name and be brought to the next activity.

In the second activity, I intend to display details about the one name the user clicked on. In addition, I want to provide navigation in this second activity that allows the user move from one name to the next: I intend to use next and previous buttons to perform this navigation.

In the above diagrams, if a user comes to Screen 1 and clicks on Giovanni, then they should get to Screen 2. On Screen 2, we have details about Giovanni. If the user presses Previous then Screen 2 should re-appear, but this time with information about Antonio, who was the name before Giovanni on Screen 1. If instead the user presses the Next button on Screen 2 (while viewing Giovanni's data) then they should be brought a view with Michele's details.

If the user navigates to the first name on the list then the Previous button should be disabled. If the user navigates to the last name on the list, then the Next button should be disabled.

With the above specification you can tell that you need access to the same list of names on both Screen 1 and Screen 2. You probably should realize that Screen 2 needs to know its current location in the list. So I would consider passing the Index into the list / array for the data that Screen 2 requires. Screen 2 could then use that index to look up the current name, and can make an identical Intent as Screen 1 does (in its onItemClicked method), but passing the current index -1 for previous, and current index + 1 for next.

I agree. Here's the link:
subject: ListView - next previous about another Activity
It's not a secret anymore!