HighLighting Selected Item in GridView

 

highlight gridview

 

In one app I was making , I needed to highlight a selected item in gridview .

What I though would be a matter of selecting some xml properties , turned out to be quite elaborate.

I was feeling lazy so here is what i did ,


grid.setOnItemClickListener(new AdapterView.OnItemClickListener()
{

@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id)
{
Toast.makeText(GridViewActvity.this, "You Clicked at " +web[+ position], Toast.LENGTH_SHORT).show();
grid.requestFocusFromTouch();
grid.setSelection(position);

}

 

This is workaround though , but might be useful in certain situations.

The full source can be downloaded here

Siyanatullah Khan

Siyanatullah Khan

Mobile Software consultant with a penchant for blogging.

More Posts

Follow Me:
TwitterLinkedInGoogle Plus

One Response

Add a Comment

HTML Snippets Powered By : XYZScripts.com