Friday 15 May 2015

java - Access Layout of another activity -



java - Access Layout of another activity -

i made music player , here design snapshot

my app design

design @ bottom mutual tabs.

here xml file tabhost , mutual design

<tabhost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignparentleft="true" android:layout_alignparenttop="true" > <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightsum="1" > <horizontalscrollview android:layout_width="fill_parent" android:layout_height="wrap_content" android:fillviewport="true" android:scrollbars="none" > <tabwidget android:id="@android:id/tabs" android:layout_width="wrap_content" android:layout_height="wrap_content"> </tabwidget> </horizontalscrollview> <framelayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1.00" android:divider="@color/list_divider" > </framelayout> <relativelayout android:id="@+id/player" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/light_grey" android:fadingedgelength="5dp" android:weightsum="1" > <textview android:id="@+id/song_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingleft="5dp" android:paddingright="5dp" android:paddingbottom="1dp" android:text="@string/all_you_need_is_love" /> <linearlayout android:id="@+id/player_art" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_centervertical="true" android:layout_below="@id/song_title" android:paddingtop="5dp" android:paddingleft="5dp" android:orientation="vertical" > <imageview android:id="@+id/player_thumbnail" android:layout_width="70dp" android:layout_height="70dp" android:background="@drawable/nocover" android:padding="4dp" android:contentdescription="@string/art_image" /> </linearlayout> <linearlayout android:id="@+id/seekbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_torightof="@+id/player_art" android:layout_aligntop="@+id/player_art" android:paddingleft="5dp" > <seekbar android:layout_width="match_parent" android:layout_height="wrap_content" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_torightof="@+id/player_art" android:layout_below="@+id/seekbar" android:paddingbottom="3dp" android:paddingleft="5dp" android:gravity="center_horizontal|center_vertical" > <imagebutton android:id="@+id/previous" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="10dp" android:padding="2dp" android:scaletype="centercrop" android:src="@drawable/rsz_previous" android:background="@drawable/custom_button" android:contentdescription="@string/play_button" /> <imagebutton android:id="@+id/play" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:padding="2dp" android:scaletype="centercrop" android:src="@drawable/rsz_play" android:background="@drawable/custom_button" android:contentdescription="@string/play_button" /> <imagebutton android:id="@+id/next" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/rsz_next" android:layout_marginleft="10dp" android:padding="2dp" android:scaletype="centercrop" android:background="@drawable/custom_button" android:contentdescription="@string/play_button" /> </linearlayout> </relativelayout> </linearlayout> </tabhost>

and xml file used showing songs named music_tab.xml

here java file , allsong contains songs title

layoutinflater inflater = (layoutinflater) getsystemservice(context.layout_inflater_service); mainview = (viewgroup) inflater.inflate(r.layout.music, null, false); songname = (textview) mainview.findviewbyid(r.id.song_title); songname.settext(allsong.get(position)); string prev = songname.gettext();

it not set song title on design prev string having value set settext() method. please help me.thanks in advance.

i have researched on thing lot no result. conclusion came upon class can access widgets nowadays in layout inflates.

java android xml

No comments:

Post a Comment