I have a listview. And i need do click in each element inside listview. But the onItemClickListener don't work. I try put each textView with focusable="false" and put android:descendantFocusability="blocksDescendants" but nothing works and i don't know where is my error.
Here is my code
xml of each element inside listview
**xml_item_list**
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="5dip"
android:paddingBottom="8dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:background="#android:drawable/list_selector_background"
android:clickable="true"
android:longClickable="true"
android:descendantFocusability="blocksDescendants">
<TextView
android:id="#+id/lDate"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:background="#drawable/et_style"
android:gravity="center"
android:textColor="#c2c2c2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:focusable="false" />
<TextView
android:id="#+id/lDescription"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:gravity="center"
android:background="#drawable/et_style"
android:textColor="#c2c2c2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:focusable="false"/>
<TextView
android:id="#+id/lMissValue"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:gravity="center_horizontal|center"
android:layout_gravity="center"
android:textColor="#DDCC2EFA"
android:textAppearance="?android:attr/textAppearanceMedium"
android:focusable="false"/>
</TableRow>
**main_xml_list**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background_tile"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="50dp">
<ImageView
android:id="#+id/bankTransaction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"/>
<TextView
android:id="#+id/contextLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/et_style"
android:textSize="28dp"
android:layout_gravity="bottom" />
</LinearLayout>
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
</ListView>
</LinearLayout>
Code inside onCreate() function of activity
onCreate()
listView = getListView();
listView.setClickable(true);
listView.setOnItemClickListener(
new OnItemClickListener()
{
#Override
public void onItemClick(AdapterView<?> arg0, View view,int position, long id) {
Log.w(TransactionView.class.getName(), "Item click listener");
Toast.makeText(TransactionView.this, "Item clicado", Toast.LENGTH_LONG).show();
}
}
);
Anyone can help me?
Thanks for yout time.
try like this
lvlList = (ListView)findViewById(R.id.lvlList);
lvlList.setOnItemClickListener(new OnItemClickListener()
{
#Override
public void onItemClick(AdapterView<?> a, View v,int position, long id)
{
Toast.makeText(getBaseContext(), "Click", Toast.LENGTH_LONG).show();
}
});
First of all,check that you have added this line or not in your code.
public class MyActivity extends Activity implements OnItemClickListener
Then add this code in your onCreate() of activity ...
ListView listView = (ListView) findViewById(R.id.lisview);
listView.setOnItemClickListener(this);
#Override
public boolean onItemClick(AdapterView<?> parent, View v, int pos,long id)
{
System.out.println("~~~~~~Item Clicked");
return false;
}
change this ::
android:id="#+id/list"
Hope this helps :)
My Solution.....
public class TransactionView extends ListActivity implements **AdapterView.OnItemClickListener**{}
**onCreate()**{
adapter = new SimpleCursorAdapter(
this,
R.layout.transaction_item_view,
c,
new String[]{MySQLiteHelper.C_TRANSACTION_DUE, MySQLiteHelper.C_TRANSACTION_DESCRIPTION, MySQLiteHelper.C_TRANSACTION_VALUE, MySQLiteHelper.C_TRANSACTION_COVERVALUE, MySQLiteHelper.C_TRANSACTION_STATE, MySQLiteHelper.C_TRANSACTION_SOURCE},
new int[]{ R.id.lDate, R.id.lDescription, R.id.lMissValue},SimpleCursorAdapter.IGNORE_ITEM_VIEW_TYPE);
}
setListAdapter(adapter);
listView = getListView();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
#Override
public void onItemClick(AdapterView<?> arg0, View view,int position, long id) {
Log.w(TransactionView.class.getName(), "Item click listener");
Toast.makeText(TransactionView.this, "Item clicado", Toast.LENGTH_LONG).show();
}
}
);
**item_list_row**
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="5dip"
android:paddingBottom="8dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:background="#android:drawable/list_selector_background"
>
<TextView
android:id="#+id/lDate"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:background="#drawable/et_style"
android:gravity="center"
android:textColor="#c2c2c2"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:id="#+id/lDescription"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:gravity="center"
android:background="#drawable/et_style"
android:textColor="#c2c2c2"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView
android:id="#+id/lMissValue"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:gravity="center_horizontal|center"
android:layout_gravity="center"
android:textColor="#DDCC2EFA"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
**main_xml_list**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background_tile"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
Related
I got a custom listview:
trainingsplan_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="270dp"
android:layout_height="match_parent"
android:id="#+id/planinfolinearlayout"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/plannametv"
android:textColor="#color/darkPrimary"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/trainingszieltv"
android:layout_below="#+id/plannametv"
android:textColor="#color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/phasendauerbereichtv"
android:layout_below="#+id/trainingszieltv"
android:textColor="#color/white"/>
</LinearLayout>
<ImageButton
android:layout_width="70dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonInfo"
android:src="#drawable/informationsmall"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_toRightOf="#+id/planinfolinearlayout"
android:background="#color/darkSecondary"
android:layout_marginTop="5dp"
android:focusable="false"
/>
</RelativeLayout>
The fragment:
final ListView planView = (ListView) getActivity().findViewById(R.id.listViewtrainingsplan);
planView.setItemsCanFocus(false);
PlanAdapter adapter = new PlanAdapter(getActivity(),R.layout.trainingsplan_item, arrayOfPlans);
planView.setAdapter(adapter);planView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
changeFocus(planView, position);
}
});
However, it does not call the method changeFocus when I try to debug.
I tried several solutions shown here on this website but none has worked for me, any ideas? Thanks in advance!
remove
planView.setItemsCanFocus(false);
I have a custom ListView item. setOnClickListener is not working. I've been searching for the solution for hours, but couldn't find anything. I think the problem is not 'set focusable false' things, because I've already done it. Please, help me.
payments_list_item.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:focusable="false"
android:focusableInTouchMode="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="12dp"
android:paddingLeft="10dp">
<ImageView
android:layout_width="46dp"
android:layout_height="35.3dp"
android:textColor="#000000"
android:id="#+id/payment_item_name2"
android:layout_gravity="center_horizontal|start"
android:src="#drawable/payments_internet"
android:textSize="20sp"
android:text="Test"
android:textStyle="bold"
android:capitalize="words" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#8c8c8c"
android:id="#+id/payment_item_name"
android:layout_gravity="center_horizontal|center"
android:textSize="20sp"
android:layout_marginLeft="10dp"
android:text="Test"
android:textStyle="bold"
android:capitalize="words" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:layout_marginTop="12dp"
android:paddingRight="10dp">
<ImageView
android:layout_width="15.3dp"
android:layout_height="20.1dp"
android:src="#drawable/arrow_right_red"
android:layout_gravity="center_vertical|right"
android:id="#+id/backButton"
android:textAllCaps = "true"
/>
</LinearLayout>
Here is my Activity onCreate:
ListView paymentsList = (ListView) findViewById(R.id.paymentsList);
paymentsList.setAdapter(testAdapter);
paymentsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.w("Clicked23", "CLicked23");
}
});
`
My Adapter:
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View payments_list_item = inflater.inflate(R.layout.payments_list_item, parent, false);
String payment = getItem(position);
TextView payment_item_name = (TextView) payments_list_item.findViewById(R.id.payment_item_name);
payment_item_name.setText(payment.toUpperCase());
return payments_list_item;
}
//EDIT
Finally solved my problem
Thanks to #mustafasevgi`s answer:
I added
android:descendantFocusability="blocksDescendants" to my custom ListView item layout.
Can you add this code?
android:descendantFocusability="blocksDescendants"
payment_list_item.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="12dp"
android:paddingLeft="10dp">
<ImageView
android:layout_width="46dp"
android:layout_height="35.3dp"
android:textColor="#000000"
android:id="#+id/payment_item_name2"
android:layout_gravity="center_horizontal|start"
android:src="#drawable/payments_internet"
android:textSize="20sp"
android:text="Test"
android:textStyle="bold"
android:capitalize="words" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#8c8c8c"
android:id="#+id/payment_item_name"
android:layout_gravity="center_horizontal|center"
android:textSize="20sp"
android:layout_marginLeft="10dp"
android:text="Test"
android:textStyle="bold"
android:capitalize="words" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:layout_marginTop="12dp"
android:paddingRight="10dp">
<ImageView
android:layout_width="15.3dp"
android:layout_height="20.1dp"
android:src="#drawable/arrow_right_red"
android:layout_gravity="center_vertical|right"
android:id="#+id/backButton"
android:textAllCaps = "true"
/>
</LinearLayout>
check the following code:
public class CustomListActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
ListView paymentsList;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_list);//your layout view
paymentsList = (ListView) findViewById(R.id.paymentsList);
paymentsList.setAdapter(testAdapter);
paymentsList.setOnItemClickListener(this);
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
//your logic
Toast.makeText(this, "Listview Clicked", Toast.LENGTH_SHORT).show();
}
}
Try this:
paymentsList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Log.w("Clicked23", "CLicked23");
}
});
Remove this from your xml
android:focusable="false"
android:focusableInTouchMode="false"
how about modifying your payments_list_item to this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="12dp"
android:paddingTop="12dp">
<ImageView
android:id="#+id/payment_item_name2"
android:layout_width="46dp"
android:layout_height="35.3dp"
android:src="#drawable/payments_internet"/>
<TextView
android:id="#+id/payment_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Test"
android:textColor="#8c8c8c"
android:textSize="20sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/backButton"
android:layout_width="15.3dp"
android:layout_height="20.1dp"
android:layout_gravity="center_vertical|right"
android:src="#drawable/arrow_right_red"/>
</LinearLayout>
you have written very complex layout..
Hi in my app I want to do some functionality on click of item in a list.
Here is the xml for the list item.
<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="#FFFFFF"
android:layout_marginTop="20dp"
android:focusableInTouchMode="true" android:focusable="true">
<TableLayout android:layout_width="fill_parent" android:layout_marginTop="10dp"
android:layout_height="wrap_content" android:id="#+checklistitem/itemrow">
<TableRow android:id="#+checklistitem/tr">
<TextView android:id="#+checklistitem/texthead"
android:textStyle="bold"
android:visibility="gone" android:layout_marginLeft="10dp"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:paddingRight="0dp" android:maxLines="2" android:textSize="16dp"
android:text="Towel Rack: 2 hand towels,2 wash clothes"
android:background="#000000" android:textColor="#ffffff"
android:layout_centerVertical="true" />
<TextView android:id="#+checklistitem/textSeparator"
android:visibility="gone" android:layout_marginLeft="10dp"
android:layout_width="240dp" android:layout_height="fill_parent"
android:paddingRight="0dp" android:maxLines="2" android:textSize="16dp"
android:text=""
android:background="#000000" android:textColor="#ffffff"
android:layout_centerVertical="true" />
<TextView android:layout_marginLeft="5dp"
android:id="#+checklistitem/inspectionvalue" android:visibility="visible"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="#006699" android:text="01"
android:layout_alignParentRight="true" android:layout_marginRight="8dp"
android:layout_centerVertical="true" />
</TableRow>
</TableLayout>
</RelativeLayout>
and here is the code where I used adapter for my list
checklistview.setOnItemClickListener(this);
CheckListAdapterForAtt checkAdapter = new CheckListAdapterForAtt(this.getApplicationContext(), checkListRowDataArr, R.layout.checklist_row);
But some how Item click listner does not working for me???
Add the following in the XML row layout where you want to click
android:clickable="false"
android:focusable="false"
Onclick listener Like following
mList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
}
});
try like this:
listView.setOnItemClickListener(new OnItemClickListener() {
private void OnItemSelected() {
}
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
if(arg2 == 0)
{
}
if(arg2 == 1)
{
}
I have an activity with a ListView. ListView with custom views. I add OnItemClickLIstener to the ListView. and when i click on item, in result i see nothing.
Activity with ListView:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#color/silver_conv">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="40dp" android:layout_alignParentTop="true" android:id="#+id/topcontainer"
android:background="#color/black">
</FrameLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/chat_list" android:layout_below="#+id/topcontainer"
android:layout_above="#+id/last_action"
android:cacheColorHint="#00000000"
android:layout_marginRight="2dp" android:clickable="true"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="last action was at time" android:id="#+id/last_action"
android:longClickable="false"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="false" android:layout_above="#+id/action_container"
android:layout_marginBottom="5dp" android:layout_alignParentLeft="false" android:layout_marginLeft="5dp"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="43dp" android:layout_alignParentBottom="true" android:id="#+id/action_container"
android:background="#drawable/conv_botom_action_gradient">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="#string/send"
android:id="#+id/send_message_btn" android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="#drawable/blue_button_selector" android:textColor="#color/white"
android:layout_marginLeft="3dp" android:layout_marginTop="3dp"/>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="#+id/add_attach_btn"
android:layout_alignParentLeft="true" android:layout_alignParentBottom="true"
android:background="#drawable/add_attach_button_selector"
android:layout_marginRight="2dp" android:layout_marginBottom="3dp" android:layout_marginTop="3dp"/>
<EditText android:layout_width="40dp" android:layout_height="wrap_content" android:id="#+id/message_et"
android:layout_toRightOf="#+id/add_attach_btn" android:layout_toLeftOf="#+id/send_message_btn"
android:singleLine="true" android:layout_alignParentBottom="true" android:hint="Type message here"
android:background="#drawable/message_input" android:layout_marginBottom="3dp"
android:gravity="center_vertical" android:layout_marginTop="3dp"/>
</RelativeLayout>
View item:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="center_vertical|left" android:focusable="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="#drawable/incoming_message"
android:id="#+id/container" android:layout_marginTop="5dp" android:layout_marginBottom="5dp"
android:focusable="false">
<FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
android:focusableInTouchMode="true" android:id="#+id/attach_container" android:focusable="false"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="saa"
android:id="#+id/message_text" android:textSize="17sp" android:textColor="#color/black"
android:focusable="false"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="#+id/date" android:textColor="#color/black" android:singleLine="true" android:lines="1"
android:maxLines="1" android:ellipsize="none" android:layout_marginLeft="5dp" android:focusable="false"/>
And finally clickListener:
private AdapterView.OnItemClickListener clickLister = new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
try {
LinearLayout container = (LinearLayout)view.findViewById(R.id.container);
TextView message = (TextView)container.findViewById(R.id.message_text);
message.setTextColor(mContext.getResources().getColor(R.color.white));
Log.e("My item is", "" + pos);
}catch (Exception e){
e.printStackTrace();
}
}
};
And here is Initialization of ListView:
mConvListView = (ListView)findViewById(R.id.chat_list);
mConvListView.setDivider(null);
mConvListView.setDividerHeight(0);
mConvListView.setItemsCanFocus(false);
mConvListView.setOnItemClickListener(clickLister);
mConvListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
mConvListView.setStackFromBottom(true);
P.s. Sorry for a lot code. But I can't find any suggestion a second day.
By setting focusable objects in your row layout, you are preventing the ListView from getting the touch event.
This FrameLayout is consuming the touch event:
<FrameLayout
android:id="#+id/attach_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:focusable="false"/>
Remove the focusable settings so it looks like this:
<FrameLayout
android:id="#+id/attach_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
(You really should organize your XML so that is is readable, in Eclipse use Ctrl+Shift+F.)
Make Focus for all components as follows :
android:focusable="false"
android:focusableInTouchMode="false"
I guess you are not getting the item the right way. Try this:
int position = (int) adapterView.getSelectedItemId();
Log.i("Position:", Integer.toString(position));
Edit
Try this piece of code.
ListView lv = (ListView)findViewById(R.id.chat_list);
lv.setOnItemClickListener(new OnItemClickListener(){
#Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
int position = (int) parent.getSelectedItemId();
Log.i("Position:", Integer.toString(position));
}
});
I got ListActivity, each item has 2 textviews image and CheckedTextView. I am trying to implement simple multichoiselist...
I have two problems:
1.
#Override
protected void onListItemClick(android.widget.ListView l, View v,
int position, long id)
{
...
}
doesnt respond at all I have tried it with the debugger and when I press on any list item it doesnt stop there. and I have tried all kind of things (like focusable:false)
two:.
I cant toggle the CheckedTextView anyhow.
here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="100sp"
android:focusable="false" android:focusableInTouchMode="false">
android:padding="6dip">
<ImageView android:layout_width="wrap_content"
android:layout_height="fill_parent" android:src="#drawable/icon"
android:id="#drawable/icon" android:layout_marginLeft="6dip"
android:focusable="false" android:focusableInTouchMode="false">
</ImageView>
<LinearLayout android:id="#+id/LinearLayout01"
android:orientation="vertical" android:layout_width="1sp"
android:layout_height="fill_parent" android:layout_weight="1"
android:focusable="false" android:focusableInTouchMode="false">
<TextView android:id="#+id/toptext" android:layout_weight="1"
android:gravity="center_vertical" android:text="OrderNum"
android:singleLine="true" android:layout_height="0dp"
android:layout_width="wrap_content" android:focusable="false"
android:focusableInTouchMode="false">
</TextView>
<TextView android:id="#+id/bottomtext" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:focusable="false"
android:focusableInTouchMode="false" android:text="TweetMsg">
</TextView>
<TextView android:id="#+id/twittLocation"
android:layout_weight="1" android:text="location" android:singleLine="true"
android:layout_width="fill_parent" android:layout_height="0dip"
android:focusable="false" android:focusableInTouchMode="false">
</TextView>
<TextView android:layout_weight="1" android:id="#+id/twittLocationlink"
android:text="locationlink" android:gravity="fill_horizontal"
android:layout_width="fill_parent" android:layout_height="0dip"
android:focusable="false" android:focusableInTouchMode="false">
</TextView>
</LinearLayout>
<CheckedTextView android:id="#android:id/text1" android:text="Delete"
android:layout_width="wrap_content" android:layout_marginRight="2dp"
android:layout_height="fill_parent"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:focusable="false"></CheckedTextView>
</LinearLayout>
any idea what's the problem?
thanks.
In your ListView set android:descendantFocusability="beforeDescendants". This might help.
Try this code:
public class Sample extends ListFragment implements OnItemClickListener{
ListView list;
list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
}
});
}
Sample code