Custom ListView row clicking behavior

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Custom ListView row clicking behavior

Postby PaulFake » Tue Oct 06, 2009 2:53 am

I have created a few ListViews with custom layouts for the rows. I noticed that the rows on these ListViews do not turn orange when clicked (as do ListViews with standard rows, such as simple_list_item_1), so I added the following line to my onItemClick handler:

class FriendListOnItemClickListener implements OnItemClickListener
{
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long id)
{
view.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.list_selector_background));
...

However, this only works sometimes, and very rarely. Usually the rows will stay white, and the rest of the code will execute fine. I would much rather see a consistent clicked-state in my custom rows, so does anyone know how to do this properly?
PaulFake
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Aug 26, 2009 1:05 am

Top

Postby PaulFake » Sat Oct 10, 2009 3:19 am

Whoops, I had set the background of my row's layout to white. It was hiding the orange click state.
PaulFake
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Aug 26, 2009 1:05 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 7 guests