ListView rows are unclickable

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

ListView rows are unclickable

Postby PaulFake » Tue Oct 06, 2009 8:57 am

Hi again,

Sorry for the flood of posts recently, but I have been saving up all of my questions and they are finally all coming out. I have created quite a few ListViews with custom row layouts, but all of a sudden the two new ones I created today do not react to clicks. That's right...they just don't fire OnItemClick in the listener that I am passing. Here is the code for one of the problematic lists:

m_listContacts = (ListView)findViewById(R.id.listcontacts);
m_listContacts.setAdapter(new ContactListAdapter(this));
m_listContacts.setTextFilterEnabled(true);
m_listContacts.setDivider(getResources().getDrawable(android.R.drawable.divider_horizontal_textfield));
m_listContacts.setClickable(true);
m_listContacts.setOnItemClickListener(new ContactListOnItemClickListener());
...
class ContactListOnItemClickListener implements OnItemClickListener
{
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long id)
{
//this code is not called
view.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.list_selector_background));
FBConnectAPIObjects.m_fbConnectAPI.APIMethodLinkContact(MatchContactScreen.this, m_handler,
BCalSharedObjects.m_aryFriends[MatchContactScreen.this.getIntent().getIntExtra("Index", 0)].m_lFacebookUserID,
Long.parseLong(m_aryContacts[position].m_strInternalId));
}
}


And here is the relevant xml information:

<ListView
android:id="@+id/listcontacts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@drawable/white"
/>

row:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/white">

<TextView
android:id="@+id/name"
android:layout_width="250dip"
android:layout_height="wrap_content"
android:inputType="text"
android:textSize="16sp"
android:textStyle="bold"
android:typeface="sans"
android:textColor="@drawable/black"
android:layout_marginTop="1dip"
android:layout_marginLeft="10dip"
android:ellipsize="end"
/>

<TextView
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:typeface="sans"
android:textColor="@drawable/black"
android:layout_below="@+id/name"
android:layout_marginLeft="10dip"
android:ellipsize="end"
/>

<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:typeface="sans"
android:textColor="@drawable/black"
android:layout_below="@+id/phone"
android:layout_marginLeft="10dip"
android:ellipsize="end"
/>

</RelativeLayout>


If anybody sees something obviously wrong with this code, then please let me know. I've compared it to my working ListViews, and it all looks pretty much the same.
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: No registered users and 7 guests