2

我尝试将焦点设置在 ListView 但 onItemSelected - 不起作用,这是我的来源

uAdapter = new UrlArrayAdapter(DatabaseTable.this, urlListView,
                urlLists);
        urlListView.setAdapter(uAdapter);
    urlListView.setItemsCanFocus(true);
        urlListView.setClickable(false);
        urlListView.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> arg0, View arg1, int pos,
                long id) {  });

我使用以下 XML。我的 LisWiev xml

    <ListView
        android:id="@+id/listView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:descendantFocusability="beforeDescendants" >
    </ListView>

和添加到 ListView 的项目 xml

    <LinearLayout
        android:id="@+id/editLinearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:minHeight="50dp" >
        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.66"
            android:ems="10" >
            <requestFocus />
        </EditText>
        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:focusableInTouchMode="false" />
    </LinearLayout>

我解决了这个问题,这篇文章帮助了我,它展示了如何使用 ListView [Linc] ( http://www.lalit3686.blogspot.in/2012/06/today-i-am-going-to-show-how-to-deal.html)

帮助我访问此链接 http://vikaskanani.wordpress.com/2011/07/27/android-focusable-edittext-inside-listview/

4

1 回答 1

0

您的 onItemSelected 没有被调用,因为您已将setClickable列表的属性设置为 false。尝试将其更改为 true,然后检查。我希望这会奏效。

于 2012-08-14T07:18:18.277 回答