i have array questions, display on screen. when click on item, go anwer. that's working fine. (header)label doesn't display question, app name.
i readed this article. every time click on question, it's different question, can't hardcoded. wen click on question new activity starts. nice if question(item of array) send new acitivity.
so listview filled items of array questions:
and new activity when click on question:
the "idp2013" has change tot question clicked on.
list_data.xml:
<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="questions"> <item>where exit button?</item> <item>why cant launch rocket?</item> <item>why cant hack other teams?</item> <item>how can home screen?</item> <item>test</item> </string-array> <string-array name="answers"> <item>right above, click button , last button "exit".</item> <item>because there no rocket.</item> <item>have patience.</item> <item>left above, click button. </item> <item>test</item> </string-array>
androidmanifest.xml:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.activity.idp2013" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="14" android:targetsdkversion="17" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > ... <activity android:name="com.activity.idp2013.singlelistitem" android:label="@array/questions"> </activity> ... </application> </manifest>
use intent.putextra pass data activity.
intent intent = new intent(this, newactivity.class); intent.putextra("questionname", array[selectedposition]); startactivity(intent);
then in newactivity string using:-
string questionname = ""; bundle extras = getintent().getextras(); if (extras != null) { this.questionname = extras.getstring("questionname"); }
and set questionname settitle of newactivity.
Comments
Post a Comment