无法在android中单击列表视图中的项目

无法在android中单击列表视图中的项目,android,list,onitemclicklistener,Android,List,Onitemclicklistener,我无法在android中单击我的列表中的项目以下是我的代码: list=(ListView) findViewById(R.id.list); list.setOnItemClickListener(this); TaskListAdapter obj = new TaskListAdapter(this.getApplicationContext() ,R.layout.row, tl); list.setAda

我无法在android中单击我的列表中的项目以下是我的代码:

list=(ListView) findViewById(R.id.list);
        list.setOnItemClickListener(this);

        TaskListAdapter obj = new TaskListAdapter(this.getApplicationContext()
                ,R.layout.row, tl);
        list.setAdapter(obj);
        //list.setItemsCanFocus(true);
        list.setClickable(true);
下面是列表适配器

LayoutInflater loi = LayoutInflater.from(con);          
        View v = loi.inflate(rid, parent, false);   
        TextView tv1 = (TextView) v.findViewById(R.id.txt1);
        TextView tv2 = (TextView) v.findViewById(R.id.txt2);
        //iv.setBackgroundResource(arrow);
        v.setClickable(true);
        v.setFocusable(true);
        final int pos = position;

        tv1.setText(objs.get(position).GuestName);
        tv2.setText(objs.get(position).TaskID);

        return v;
这是我的点击项目处理程序

@Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//      Intent in = new Intent();
//      in.putExtra("GuestID", tl.get(arg2).GuestID);
//      in.putExtra("ReservationID", tl.get(arg2).ReservationID);
//      in.putExtra("CustomerID", custId);
//      in.putExtra("Token", token);
        getGuestDetails(tl.get(arg2).GuestID, tl.get(arg2).ReservationID);

    }
@覆盖
公共视图单击(AdapterView arg0、视图arg1、整型arg2、长型arg3){
//Intent in=新Intent();
//in.putExtra(“GuestID”,tl.get(arg2.GuestID);
//in.putExtra(“ReservationID”,tl.get(arg2.ReservationID);
//in.putExtra(“CustomerID”,custId);
//in.putExtra(“令牌”,令牌);
getGuestDetails(tl.get(arg2).GuestID,tl.get(arg2).ReservationID);
}
这是xml

<?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="#f1eff0">


    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:stretchColumns="1" android:gravity="center_vertical"
        android:background="@drawable/toptab" android:id="@+id/tb1">

        <TableRow>

            <Button android:id="@+id/btnback" android:background="@color/hover_bckbtn"
                android:text="Back" android:textColor="#ffffff" android:textSize="14sp"
                android:textStyle="normal" android:typeface="normal"
                android:layout_marginLeft="5dp" />


            <TextView android:id="@+id/tvnormalcallreg" android:text="List View"
                android:textColor="#ffffff" android:textSize="18sp"
                android:layout_gravity="center" android:textStyle="normal"
                android:typeface="normal" />

            <Button android:id="@+id/btnregister" android:textColor="#ffffff"
                android:background="@color/hover_button" android:text="Register"
                android:textSize="14sp" android:textStyle="normal" android:typeface="normal"
                android:layout_marginRight="5dp" />
        </TableRow>
    </TableLayout>

    <ListView android:id="@+id/list" 
    android:scrollbars="none"
        android:layout_below="@+id/tb1"  
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp" 
        android:layout_width="fill_parent" 
        android:cacheColorHint="#00000000"
        android:fadingEdge="none"
        android:layout_marginBottom="50dp"/>

    <TableLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:layout_alignParentBottom="true"
        android:id="@+id/bottom">

        <TableRow android:background="@drawable/toptab"
            android:gravity="center">

            <ImageView android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:background="@drawable/logobottom" />
        </TableRow>

    </TableLayout>



</RelativeLayout>


请帮帮我,我是android新手???

你真的有点击监听器吗?我可以看到您将click listener设置为该值,但您尚未添加显示click listener实现的代码。

您确实有click listener吗?我可以看到您将click listener设置为此,但您尚未添加显示click listener实现的代码。

问题已解决

我把这些行注释掉了

v.setClickable(true);
v.setFocusable(true);
我的代码运行正常,问题解决了

我把这些行注释掉了

v.setClickable(true);
v.setFocusable(true);

我的代码工作了

您是否在适配器中实现了方法
isEnabled(int位置)
?适配器的方法。只需为应可单击的项返回
true
,为所有其他项返回
false
。您的listview是否在某个scrollview中?否,在此处添加了xml,您可以看到,您需要传递一个onItemClickListener而不是在onItemClickListener中传递上下文,您是否实现了方法
isEnabled(int位置)
在适配器中?适配器的方法。只需为应可单击的项目返回
true
,为所有其他项目返回
false
。您的listview是否在某个滚动视图中?否,在此处也添加了xml,您可以看到,您需要传递一个onItemClickListener,而不是在onItemClickListener中传递上下文,OnClickListener出现了什么错误,您确定没有单击它吗?(您是否尝试从侦听器向LogCat打印内容)没有收到任何错误,但我无法单击列表中的项目我正在打印语句,并且正在调试,并且没有在listner中获得控件???实现McClickListener,OnClickListener您收到了什么错误,您确定没有单击它吗?(您是否尝试从侦听器向LogCat打印内容)没有收到任何错误,但我无法单击列表中的项目我正在打印一条语句,并且我正在调试,无法在其列表中获得控制权????