2012-10-26 31 views
1

我无法点击我的机器人在这里清单上的项目列表视图项目是我的代码:无法点击在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); 

    } 

这里是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新手?

+0

你实现方法'的IsEnabled(INT位置)'适配器? – Jin35

+0

不是这是什么? –

+0

适配器的方法。只需为所有其他应该可点击的项目和“false”项目返回“true”。 – Jin35

回答

0

你确实有点击监听器吗?我可以看到你将点击监听器设置为这个,但是你还没有添加显示点击监听器实现的代码。

+0

是的,编辑有问题的代码 –

+0

实现OnItemClickListener,OnClickListener –

+0

你得到了什么错误,你确定它没有被点击吗? (您是否尝试从监听器打印LogCat的东西) – JustDanyul

1

问题解决了

我注释掉这些行

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

和我的代码工作