각 목록 항목에 textviews와 viewpager가있는 listview가 있습니다. 나는 Airbnb 앱과 마찬가지로 viewpager를 통해 각 listitem에서 스크롤 가능한 이미지를 원한다.목록보기 행 내 Viewpage
구현하려고했지만 문제는 목록 어댑터에서 새 viewpager 인스턴스를 만들고 viewpager에 새 ID를 설정해야한다는 것입니다. 또한 새로운 FragmentStatePagerAdapter를 만들고 viewpager에 설정할 때마다. 뷰 페이지 및 어댑터 재사용시 앱이 다운됩니다.
그래서 listview에서 뷰 페이지를 통합 할 수있는 방법이나 라이브러리가 있습니까 ??
여기 내 코드 SimpleCursorAdapter를 listview에 사용하고 SimpleCursorAdapter.ViewBinder를 사용하여 뷰 페이지 어댑터를 바인딩합니다.
SimpleCursorAdapter.ViewBinder
...
enter code here
listPager = new ViewPager(MainListActivity.this);
listPager.setId(R.id.viewpager_id_base + cursor.getPosition() + 1);
listPager.setPageMargin(-(int) (pageMargin * 1.5));
listPager.setLayoutParams(pagerParams);
imageList = MainListDAO.getMedia(rowId);
mediaAdapter = new ViewPagerAdapter(getSupportFragmentManager(), imageList);
mediaAdapter . setCount(imageList.size());
listPager.setAdapter(mediaAdapter);
...
listitem.xml
...
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingTop="5dp" >
<TextView
android:id="@+id/txtCommentCount"
style="@style/textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/txtSending"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="@drawable/clock" />
<ImageView
android:id="@+id/imgMute"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:padding="5dp"
android:src="@drawable/ic__mute_small" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/lytMedia"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_default_margin"
android:focusable="false"
android:focusableInTouchMode="true" >
</android.support.v4.view.ViewPager>
</LinearLayout>
...
이미 시도한 코드를 게시하면 도움이 될 것입니다. – Blacklight
[도움이 될 수도 있습니다] (http://dallasgutauckis.com/2013/04/30/android-putting-a-viewpager-inside-a-listview/) * - thanks Google. * [this one] (http : //stackoverflow.com/questions/14920459/placing-viewpager-as-a-row-in-listview), [another one] (http://stackoverflow.com/questions/21334599/android-listview-with-swipe- 내부 - 뷰 페이지) 및 [그 하나] (http://stackoverflow.com/questions/17173545/multiple-viewpages-inside-single-listview-is-crashing) * - 감사합니다. * – Fllo
왜 새로운 ID가 뷰 페이지에 있습니까? 필요한 경우 어댑터를 다시 작성해야하지만 가능한 경우 데이터 세트를 변경할 수는 있습니다. 하지만 확실히 뷰 페이지를 재사용 할 수 있습니다. – rekaszeru