The first two pages with the same value in the Android pager view. How to disable it?

I want to get data from a database using the current position of the view pager in android, but when I tried it, the first two pages use the same number. Is there a way to use the current pager position to retrieve data?

public void onPageSelected(int arg0) { int a = arg0 + 1; } 

I passed the value of 'a', but the second page also used the value of a as 1 in the pager view.

I used the following in the snippet:

DBMain dbm1 = new DBMain (context); dbm1.open ();

  Cursor cursor = dbm1.getSGGS(no);//'no' is the number 'a' if (cursor.moveToNext()) { for (int i = 0; i < cursor.getCount(); i++) { array.add(cursor.getString(cursor .getColumnIndex("abc"))); cursor.moveToNext(); 

}

But the first two will use "a" as 1. I want the second fragment to use "a" as 2, and then 3 ......

Thanks at Advance

+4
source share
1 answer

Reset error. Get the value onCreate instead of onCreateView.

thanks for the answer

0
source

Source: https://habr.com/ru/post/1497780/


All Articles