![](/img/trans.png)
[英]How do I set up onClickListener for ListView binded to custom adapter?
[英]How do I set up an Adapter for this ViewPager and TextViews layout?
我有這樣的布局:
TextViews
ViewPager
(藍色方塊) 它看起來像這樣:
這是xml代碼:
<RelativeLayout
android:id="@+id/parte_sopra"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/accordo_view_nome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:layout_marginStart="10dp"
android:textSize="25sp"
android:text="TEXTVIEW"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif-condensed"
android:textStyle="bold"
android:textColor="@color/black" />
<TextView
android:id="@+id/accordo_view_note"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="TEXTVIEW"
android:textSize="24sp"
android:layout_marginTop="12dp"
android:layout_marginEnd="10dp"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_height="250dp"
android:layout_width="match_parent"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="10dp" />
我需要使用從MainActivity
獲得的List
中獲得的項目來對它進行MainActivity
,如下所示:
chords = new ArrayList<Accordo>();
chords.add(new Accordo(R.drawable.do_maggiore, R.drawable.do_maggiore2, R.drawable.do_maggiore3, "Do maggiore", "Do, Mi, Sol"));
chords.add(new Accordo(R.drawable.do5, R.drawable.do5_2, R.drawable.do5_3, "Do 5", "Na, na, na"));
chords.add(new Accordo(R.drawable.do6, R.drawable.do6_2, R.drawable.do6_3, "Do 6", "Note: na, na, na"));
chords.add(new Accordo(R.drawable.do7, R.drawable.do7_2, R.drawable.do7_3, "do 7", "Note: na, na, na"));
ViewPager
到ViewPager
String
進入粗體 TextView
String
放入常規TextView
我會很感激您能為我提供的任何幫助!
您需要創建自定義的PagerAdapter類,您必須將其設置為ViewPager。 有關更多信息,請檢查此答案: https : //stackoverflow.com/a/32155161/5519005
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.