2

Good evening folks,

so I'm developing an app which should assist swimming team trainers in taking times for their students.

For that purpose I added an activity displaying a list of swimmers. Clicking once on a swimmer's row causes the stop clock to start ticking.

Clicking consecutive times should display the current time as an temporary interval time keeping the main clock unchanged.

This worked for me until I wanted to realize the display of interval time as another list within a list item of the outer list. What happens is that clicking the first time adds the first row of the interval list, but after then I cannot click the outer list item again to add more interval time rows.

I hope I could explain how this activity is structured. here a screenshot of the activity:

https://dl.dropboxusercontent.com/u/48419555/Screen.png

this is my activity's java file. it is the method handling the inner list view:

    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);

    }

it's Layout file:

<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>

outer list item layout file:

<?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>

inner list (interval list) item layout

<?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>

I tried to mess with the list items xml file to make it unclickable, because my assumption is that the inner list "blocks" the outer one.

Hope someone knows how to fix this

0 Answers0