Reputation: 1
what I am trying to do is to display an item on text on the screen and then following the user input chage that text to the next/previous item.
I have created a string arry with all the items in (xml) I have then called the array in the Java code and set up the OnclickListners. My problem is that I don't know what is write in the switch case(s) to make the screen display the next/last item in the list.
Any suggestions?
Upvotes: 0
Views: 589
Reputation: 14841
Your question is not so clear, I suggest you show us your code (how you create the array, the TextView, the button), it will be easier to help you complete it.
What I would do to iterate a String array would be something like this:
String[] myArray={"s1","s2","s3"};
TextView myTextView; //suppose myTextView has already been created and added to your layout
int currentIndex=0;
private void onClick(View v) {
if (currentIndex<myArray.length) {
myTextView.setText(myArray[currentIndex]);
currentIndex++;
}
}
Upvotes: 1