Android BaseAdapter时未调用listview onItemClick

Android BaseAdapter时未调用listview onItemClick,android,android-listview,Android,Android Listview,我花了一个小时试图弄明白这个问题。在实现我自己的适配器时,不会调用listview的onClick事件 自定义布局xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <CheckBox android:id="@+i

我花了一个小时试图弄明白这个问题。在实现我自己的适配器时,不会调用listview的onClick事件

自定义布局xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<CheckBox
    android:id="@+id/check"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginLeft="4px"
    android:layout_marginRight="10px" >
</CheckBox>


<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="23dp"
    android:layout_marginTop="10dp"
    android:layout_toRightOf="@+id/imageView1"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:text="CodeLearn Chapter 1"
    android:textSize="16sp" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/imageView1"
    android:layout_alignLeft="@+id/textView1"
    android:clickable="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:text="Description" />

  </RelativeLayout>
  <?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:orientation="vertical" >

<TextView
    android:id="@+id/tvUserName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="false"
  />


<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</ListView>

    </LinearLayout>
主要活动

public class MainActivity extends Activity
{

    AssignmentAdapter   assignmentAdaper;
    Context             context = MainActivity.this;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.home_page);
    assignmentAdaper = new AssignmentAdapter(this);

        ListView assignmentLists = (ListView) findViewById(R.id.listView1);
        assignmentLists.setAdapter(assignmentAdaper);

        Assignment myAssignment = new Assignment();

        assignmentLists.setOnItemClickListener(new OnItemClickListener()
        {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
            {
                Log.d("MainActivity", "wewew");

            }
    });
公共类MainActivity扩展活动
{
分配适配器分配适配器;
Context=MainActivity.this;
@凌驾
创建时受保护的void(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.home_页面);
assignmentAdaper=新的AssignmentAdapter(此);
ListView assignmentLists=(ListView)findViewById(R.id.listView1);
assignmentLists.setAdapter(assignmentAdaper);
分配myAssignment=新分配();
assignmentLists.setOnItemClickListener(新的OnItemClickListener()
{
@凌驾
公共视图单击(AdapterView arg0、视图arg1、整型arg2、长型arg3)
{
日志d(“主要活动”、“WEW”);
}
});

因为,我在listview布局中有复选框。我需要禁用复选框的焦点属性

   <CheckBox
    android:id="@+id/check"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginLeft="4px"
    android:layout_marginRight="10px"
    android:focusable="false"
    android:focusableInTouchMode="false" >
</CheckBox>


您是在单击复选框还是在单击列表项?它们不能同时单击。请单击列表项。000@SeahawksRdaBest我发布了他们的帖子,其中一个问题可能是您将setContentView()设置错误,请将其设置为R.layout.main\u layout看看这是否有帮助
   <CheckBox
    android:id="@+id/check"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginLeft="4px"
    android:layout_marginRight="10px"
    android:focusable="false"
    android:focusableInTouchMode="false" >
</CheckBox>