小编Kin*_*ink的帖子

Android中的首选项活动中的数字首选项

我想做的是我正在制作一个生命游戏计划.我想花时间延迟并优先考虑,但我想让人们可以在特定时间输入.数字可以是几毫秒或几秒.

然而,我有点坚持如何继续,我还没有找到一个已经处理过的简单偏好,但可能有一个.是否有一种简单的方法来确定此偏好并确认输入的数据是整数还是漂浮?

android preferenceactivity android-preferences

40
推荐指数
4
解决办法
3万
查看次数

使用具有false focusable的复选框仍然可以防止listview点击

您好我已经阅读了很多关于Android中CheckBox/ListView问题的内容.所以我尝试了很多问题.

开始我的行布局看起来像这样.

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <CheckBox 
            android:id="@+id/check" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:focusable="false"
            android:focusableInTouchMode="false" 
            android:text="" /> 
   </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

那么我尝试将其添加到我的ListActivity中

 ListView listview = getListView();
 listview.setItemsCanFocus(false);
Run Code Online (Sandbox Code Playgroud)

然后尝试在onListItemClick上使用断点运行它,仍然没有命中(当然正在运行调试).

这是我的onListItemClick,以防你想看.

@Override
    protected void onListItemClick(ListView l, View v, int position, long id) {

        // let's find the checkbox we're on.
        CheckBox targetCheckBox = (CheckBox) l.findViewById(R.id.check);

        // ok update the database with the new data. 
        mDbHelper.updateNote(id, !targetCheckBox.isChecked());

        // update the list now.
        showList();

    }
Run Code Online (Sandbox Code Playgroud)

如果我然后将Checkbox更改为CheckTextView,它确实有效,但我以前从未这样做过,而且当其他人解决了这个问题时,我宁愿弄清楚这里究竟出了什么问题.有什么想法吗?

java checkbox android listview

4
推荐指数
1
解决办法
6318
查看次数