Google의 android-developer 포럼에 같은 질문을 게시했습니다. 여기에서 반복 중입니다 :ListViews inside TableLayout
하나의 TableRow가있는 TableLayout이 있습니다. 첫 번째 열/셀은 ListView입니다. 두 번째 셀/열은 두 개의 ListView로 구성된 TableLayout입니다.
xml 레이아웃을 부 풀릴 때 모든 것이 잘 보이고 각 ListView에 대해 개의 어댑터가 설정되었습니다.
나는 어댑터를 통해 이러한 목록에 더미 요소를 추가했으며 은 목록을 위아래로 스크롤 할 수 있습니다.
하지만 onItemClick이 실행되지 않습니다.
다음
내 레이아웃 파일입니다 -그리고 자바 파일에서, 내가
ListView lv = (ListView) findViewById(R.id.listView1);
lv.setAdapter(new EfficientAdapterLeft(this));
lv.setOnItemClickListener(new OnItemClickListener()
{ @Override 공공 무효 onItemClick 할
<RelativeLayout android:id="@+id/top_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:text="Edit"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<TextView
android:text="dummy1"
android:textStyle="bold"
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/button1"
android:layout_centerVertical="true"
android:paddingLeft="25dip"
android:textSize="18dip">
</TextView>
<Button
android:id="@+id/button2"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Cancel"
android:layout_alignParentRight="true">
</Button>
<TextView
android:layout_alignParentTop="true"
android:text="dummy2"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/textView4"
android:layout_toLeftOf="@+id/button2"
android:layout_centerVertical="true"
android:paddingRight="25dip"
android:textSize="18dip">
</TextView>
</RelativeLayout>
<TableLayout android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="1">
<TableRow android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@android:color/black"
android:dividerPadding="2dip">
<ListView
android:id="@+id/listView1"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
>
</ListView>
<TableLayout android:id="@+id/tableLayout2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:shrinkColumns="1">
<TextView
android:text="dummy3"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:padding="8dip"
android:textSize="18dip"
android:background="#ff238E23">
</TextView>
<ListView
android:id="@+id/listView2"
android:layout_height="0dip"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:divider="@android:color/white"
android:dividerHeight="2dip"
android:layout_width="match_parent"
android:clickable="true"
android:focusable="true"
>
</ListView>
<TextView
android:text="dummy4"
android:textSize="18dip"
android:textStyle="bold"
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff0000ff"
android:padding="8dip">
</TextView>
<ListView
android:id="@+id/listView3"
android:layout_height="0dip"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:divider="@android:color/white"
android:dividerHeight="2dip"
android:layout_width="match_parent"
android:clickable="true"
android:focusable="true"
>
</ListView>
</TableLayout>
</TableRow>
</TableLayout>
(AdapterView arg0, 뷰 뷰, int arg2, long arg3) { Log.v ("blah", "arg2"+ arg2); Log.v ("blah", "arg3"+ arg3); } });
나머지 두 목록에 대해 비슷한 작업을 수행합니다. R.id.listView2 및 R.id.listView4. 그들은 다른 어댑터를 인스턴스화하지만 아무 것도 과 크게 다릅니다.
로그가 인쇄되지 않습니다. 항목을 클릭 할 수없고 onClickItem 수신기가 트리거되도록하는 이유는 무엇입니까? 이렇게해도 lv.setFocusable (true); lv.setClickable (true); 도움이되지 않습니다.
어떤 현상이 발생하고 있는지 알 수 있습니까?
감사합니다.
아래 답변을 요청 했어야합니다. 목록보기에 콘텐츠를 채우고 있습니까? 나는 내가 무엇을 묻고 있는지 짐작한다. 당신이 그들을 클릭하려고 할 때 listviews에서 무엇이든 볼 수 있는가? –