ListIterator - One button for next, one for previous but it takes 2 clicks to move on the list

70 Views Asked by At

I have a textview where I load the 0 value by using textView.setText(nameofstory.next()); But when I go into the application and use the buttons to move left and right on the list I need to press it twice to get to the next/previous value Any help please?

private List<String> nameofstory
nameofstorylist = new ArrayList<String>();
    nameofstory.add("test");
    nameofstory.add("tests");
    nameofstory.add("test1s");
    nameofstory.add("test2s");   
ListIterator<String> nameofstory = nameofstorylist.listIterator();    
textView.setText(nameofstorylist.get(0));      


public void NextButton(View view) {

    if (nameofstory.hasNext()){
        textView.setText(nameofstory.next());
    }


}

public void BackButton(View view) {
    if (nameofstory.hasPrevious()){
        textView.setText(nameofstory.previous());
    }

}
1

There are 1 best solutions below

0
Amit On
   android:focusable="true"
   android:focusableInTouchMode="true"

and make sure that you are not using onClick on your layout xml.