당신의 도움이 필요합니다! OnItemClickListener 조각에서 작동하지 않습니다 (Multicolumn ListView)
난 조각 중 하나가 ListFragments가 스크롤 뷰 박스되는 여러 열 목록보기 포함 인 2 명 단편 (헤더 하나와 다중 열 목록에 대해 하나)을 포함하는 메인 활성을 갖는다. 이 ListFragment는 onItemClickListener 메서드를 재정의합니다. 뷰와 모든 것을 스크롤 할 수 있지만 listview를 클릭하면 리스너가 호출되지 않습니다!저는 여러 가지 솔루션을 시도했습니다.보기에 대한 집중 가능성을 차단하는 것과 같지만 지금까지 아무 것도 작동하지 않았습니다. 어쩌면 너희들이 나를 도울 수있을거야.
두 조각을 포함하는 부모 활동
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:descendantFocusability="blocksDescendants"
tools:context=".MainWindow"
>
<fragment
android:id="@+id/headerfragment"
android:name="lindcom.mobile.estock.fragments.ListHeaderFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
/>
<fragment
android:id="@+id/unitlistfragment"
android:name="lindcom.mobile.estock.fragments.UnitsListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
/>
</LinearLayout>
입니다 내 다중 열 목록에 사용할 레이아웃 :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:focusableInTouchMode="false"
android:descendantFocusability="blocksDescendants" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:id="@+id/unitsCol1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.40"
android:ellipsize="marquee"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
/>
<TextView
android:id="@+id/unitsCol2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.40"
android:ellipsize="marquee"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
/>
<TextView
android:id="@+id/unitsCol3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:ellipsize="marquee"
android:maxLines="1"
android:scrollHorizontally="true"
android:singleLine="true"
/>
</LinearLayout>
</ScrollView>
내가 가진 후 위의 레이아웃, 비동기 작업에 채워집니다 데이터를 가져 왔습니다.
ListAdapter adapter = new SimpleAdapter(
fragment.getActivity().getBaseContext(), this.unitList,
R.layout.unit_list_item, new String[] { TAG_OWNER, TAG_NAME,
TAG_CONTENT }, new int[] { R.id.unitsCol1, R.id.unitsCol2,
R.id.unitsCol3 });
fragment.setListAdapter(adapter); // Set the adapter to the listFragment
다음에 클릭 리스너의 경우 간단히 t 그는 조각 :
public class UnitsListFragment extends ListFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Fetch stuff here
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
String type = l.getItemAtPosition(position).getClass().toString();
Log.d("Item type was", type);
// THIS IS NEVER INVOKED :(
};
}
나는 많은 다른 것들을 시도했지만 어쩌면 너희들은 내가 간과했을지도 모를 간단한 수정을 볼 수있다.
도움이 될 것입니다. 감사!
ScrollView에 ListView가 있다고합시다. 그럴까요? 그렇다면 행복 파트너십이 거의 없으며 이유가 될 수 있습니다. – NigelK