java - How to pass single List Items from one Activity to another and how to adapt them to the Layout -


in mainactivity have got recyclerview inflated arraylist<> have in mainactivity.

when tap on item in recyclerview open activity inflated same strings , images using in recyclerview plus more images have put in pagerview.

the questions following:

  • how can pass single listitem activity?

  • how create adapter inflate both pagerview , textviews?

  • is 1 i'm suggesting enough way achieve i'm trying achieve, or there simplier, more efficient way it?

i appreciate give me, know isn't easy understand please if not clear, don't hesitate ask.

edit:

this how arraylist looks like:

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")); //more items 

edit 2

this xml need create adapter for:

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

what kind of adapter should use?
pageradapter though have 2 textviews outside pagerview?

you should use parcelable pass data between activity.

example: set data after click on item (in first activity)

intent.putextra("data_id", my_data); 

get data (secound activity)

bundle data = getintent().getextras(); my_data mydata = (my_data) data.getparcelable("data_id"); 

more here: https://developer.android.com/reference/android/os/parcelable.html

you can use serializable. serializable easier implement slower recommend parcelable

how create adapter inflate both pagerview , textviews? - more details please


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -