android - Click on first item in a GridView is not working -


i have activity contains gridview, each element of gridview contains imageview , when activity starts want perform click on first item's imageview. have tried several things did not work:

gridview.performitemclick(gridview.getchildat(0), 0, gridview.getadapter().getitemid(0)); 

and performclick() directly.

however think found way calling function (performemptyclick()) inside custom gridviewadapter performs click on first item's imageview.

my problem performemptyclick() called before adapter's getview() called (from debugging) , therefore onclicklistener() of imageview not set yet. here code:

gridview = (gridview) findviewbyid(r.id.foldergridview); folderviewadapter = new folderviewadapter(this, r.layout.folder_item_layout, folderitems); gridview.setadapter(folderviewadapter);  bundle extras = getintent().getextras(); nofolder = extras.getboolean("nofolder");  if (nofolder) {     folderviewadapter.performemptyclick(); } 

can me fix this?

try

gridview = (gridview) findviewbyid(r.id.foldergridview); folderviewadapter = new folderviewadapter(this,  r.layout.folder_item_layout, folderitems); gridview.setadapter(folderviewadapter);  bundle extras = getintent().getextras(); nofolder = extras.getboolean("nofolder");  if (nofolder) {   gridview.getchildat(0).performclick(); } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -