Android 包含内部ListView的ListView项不可单击

Android 包含内部ListView的ListView项不可单击,android,listview,clickable,Android,Listview,Clickable,各位晚上好 因此,我正在开发一个应用程序,它应该可以帮助游泳队教练花时间进行训练 他们的学生 为此,我添加了一个显示游泳运动员名单的活动。 在游泳运动员的一排上单击一次会导致停止时钟开始滴答作响 单击连续时间应将当前时间显示为临时间隔 保持主时钟不变的时间 这对我来说很有效,直到我想把间隔时间作为另一个时间来显示 在外部列表的列表项中列出。 第一次单击会添加间隔列表的第一行, 但此后,我无法再次单击外部列表项以添加更多间隔时间行 我希望我能解释一下这项活动是如何组织的。 下面是活动的屏幕截图:

各位晚上好

因此,我正在开发一个应用程序,它应该可以帮助游泳队教练花时间进行训练 他们的学生

为此,我添加了一个显示游泳运动员名单的活动。 在游泳运动员的一排上单击一次会导致停止时钟开始滴答作响

单击连续时间应将当前时间显示为临时间隔 保持主时钟不变的时间

这对我来说很有效,直到我想把间隔时间作为另一个时间来显示 在外部列表的列表项中列出。 第一次单击会添加间隔列表的第一行, 但此后,我无法再次单击外部列表项以添加更多间隔时间行

我希望我能解释一下这项活动是如何组织的。 下面是活动的屏幕截图:

这是我的活动的java文件。它是处理内部列表视图的方法:

    private void populateIntervalList(Long time, View view, int position) {

        int secs = (int) (time / 1000);
        int mins = secs / 60;
        secs = secs % 60;
        int milliseconds = (int) (time % 1000);

        String result = "" + mins + ":" + String.format("%02d", secs) + ":"
                + String.format("%03d", milliseconds);

        //myItems.add(result);
        listOfLists.get(position).add(result);

        //Configure ListView
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                R.layout.interval_list_item, listOfLists.get(position));

        ListView list = (ListView) view.findViewById(R.id.timer_list_interval_list);
        list.setAdapter(adapter);

    }
private void populateIntervalList(长时间、视图、int位置){
整数秒=(整数)(时间/1000);
整数分钟=秒/60;
秒=秒%60;
整数毫秒=(整数)(时间%1000);
字符串结果=”“+mins+”:“+String.format(“%02d”,秒)+”:”
+格式(“%03d”,毫秒);
//添加(结果);
获取(位置)、添加(结果);
//配置ListView
ArrayAdapter=新的ArrayAdapter(此,
R.layout.interval_list_item,listOfLists.get(position));
ListView list=(ListView)view.findViewById(R.id.timer\u list\u interval\u list);
list.setAdapter(适配器);
}
它的布局文件:

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

    <ListView
        android:id="@+id/listTimer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/start_everything"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

    </ListView>

    <Button
        android:id="@+id/start_everything"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="16dp"
        android:text="Starte Alle" />

</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/timer_list_swimmer_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_weight="1"
        android:text="name"
        android:textSize="40sp" />

    <TextView
        android:id="@+id/timer_list_interval_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="14dp"
        android:layout_toRightOf="@+id/timer_list_current_time"
        android:layout_weight="0.5"
        android:text="interval" />

    <ListView
        android:id="@+id/timer_list_interval_list"
        android:layout_width="33dp"
        android:layout_height="33dp"
        android:layout_alignBottom="@+id/timer_list_swimmer_name"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@+id/timer_list_interval_time"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:longClickable="false"
        android:scrollbarAlwaysDrawVerticalTrack="false" >

    </ListView>

    <TextView
        android:id="@+id/timer_list_current_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/timer_list_swimmer_name"
        android:layout_weight="0.5"
        android:text="00:00:000" />

</RelativeLayout>

外部列表项布局文件:

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

    <ListView
        android:id="@+id/listTimer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/start_everything"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

    </ListView>

    <Button
        android:id="@+id/start_everything"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="16dp"
        android:text="Starte Alle" />

</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/timer_list_swimmer_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_weight="1"
        android:text="name"
        android:textSize="40sp" />

    <TextView
        android:id="@+id/timer_list_interval_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="14dp"
        android:layout_toRightOf="@+id/timer_list_current_time"
        android:layout_weight="0.5"
        android:text="interval" />

    <ListView
        android:id="@+id/timer_list_interval_list"
        android:layout_width="33dp"
        android:layout_height="33dp"
        android:layout_alignBottom="@+id/timer_list_swimmer_name"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@+id/timer_list_interval_time"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:longClickable="false"
        android:scrollbarAlwaysDrawVerticalTrack="false" >

    </ListView>

    <TextView
        android:id="@+id/timer_list_current_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/timer_list_swimmer_name"
        android:layout_weight="0.5"
        android:text="00:00:000" />

</RelativeLayout>

内部列表(间隔列表)项目布局

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textSize="14sp"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:clickable="false" >


</TextView>

我试图弄乱列表项xml文件,使其不可读取,因为我的 假设内部列表“阻塞”外部列表


希望有人知道如何解决这个问题,请阅读。我删除了一些java文件行。只剩下处理内部ListView的函数,不要像这样嵌套ListView。找到其他方式来显示信息。我肯定还有其他方式,但这种方式不可能实现吗?将内部ListView更改为GridView,不幸地得到了相同的结果