I have a GridView
in an Activity
and I want to scroll the GridView
to a specific position using the scrollTo()
method. Specifically, scroll the GridView
by scrollTo()
and alert a Dialog
in the OnItemClickListener()
, scroll back by scrollTo()
in PositiveButton
click.
If I just click the items in the GridView
, it works well, but if I click the items after scrolling the GridView
by finger, the GridView
will scroll to the specific position and then scroll back immediately. I don't know why or how to deal with it.
gv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
gv.scrollTo(0, 200);
AlertDialog.Builder dilog =new AlertDialog.Builder(MainActivity.this);
dilog.setPositiveButton("aa", new OnClickListener(){
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
gv.scrollTo(0, 0);
}
});
dilog.create().show();
}
});