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
source share