i’m trying to get string using intent and webview but that string that show just one string like xc_info but I want to show all the strings.
here’s my string :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="xc_info">Dirancang untuk lintas alam ringan hingga sedang. Didesain agar efisien dan optimal pada saat mengayuh dan menanjak di jalan aspal hingga jalan tanah pedesaan. Sangat disarankan bagi pemula yang ingin memulai bermain MTB.</string>
<string name="am_info">Dirancang untuk lintas alam berat seperti naik turun bukit, masuk hutan, melintasi medan berbatu, dan menjelajah medan offroad jarak jauh. Keunggulan all mountain ada pada ketahanan dan kenyamanannya untuk dikendarai. Namun kurang efisien dipakai pada medan tanjakan yang panjang dan curam. Hampir semua sepeda AM bertipe full-suspension.</string>
<string name="fr_info">Dirancang untuk mampu bertahan menghadapi drop off (lompatan) tinggi dan kondisi ekstrim sejenisnya. Bodinya kuat namun tidak secepat dan selincah all mountain karena bobotnya yang lebih berat. Kurang cocok untuk dipakai jarak jauh dan sangat tidak cocok untuk tanjakan.</string>
<string name="dh_info">Dirancang agar dapat melaju cepat, aman dan nyaman dalam menuruni bukit dan gunung. Mampu menikung dengan stabil pada kecepatan tinggi dan selalu dilengkapi suspensi belakang untuk meredam benturan yang sering terjadi. Sepeda DH tidak mengutamakan kenyaman mengayuh karena hanya dipakai untuk turun gunung. Sepeda downhill juga lebih mengacu pada lomba, sehingga yang menjadi titik tekan dalam perancangannya adalah bagaimana agar kuat namun dapat melaju dengan cepat. Untuk menuju ke lokasi, para downhiller tidak mengayuh sepeda mereka namun diangkut dengan mobil. Tidak efisien dipergunakan di dalam kota maupun di jalur cross country.</string>
<string name="dj_info">Nama lainnya adalah trial atau urban MTB. Sepeda jenis ini awalnya didesain untuk anak muda perkotaan yang menggunakan sepeda gunung selain sebagai alat transportasi, ngebut di jalanan kota, juga digunakan untuk melakukan atraksi lompatan tinggi dan ekstrim. Fungsinya mirip BMX namun dengan bentuk yang diperbesar.</string>
<string name="rb_info">Road Bike lebih akrab dikenal dengan sepeda balap, dengan bentuknya yang khas dan fungsinya lebih untuk medan jalan aspal (road). Road Bike merupakan tipe sepeda yang dikhususkan untuk balapan dijalanan dan dirancang sedemikian mungkin untuk cepat. Dengan ban yang tipis Road Bike melaju cepat dan dengan bantuan pengaturan gigi, Road Bike bisa melaju dengan sangat cepat.</string>
</resources>
and here’s my activity to call vebview using intent:
public void onClick(DialogInterface dialog, int item) {
// TODO Auto-generated method stub
Intent intent = new Intent(Tab_Brand_ListView_Activity.this, Tab_Bike_Information_Activity.class);
switch (item) {
case 0:
intent.putExtra("text", items);
startActivity(intent);
break;
case 1:
intent.putExtra("text", items);
startActivity(intent);
break;
case 2:
intent.putExtra("text", items);
startActivity(intent);
break;
case 3:
intent.putExtra("text", items);
startActivity(intent);
break;
case 4:
intent.putExtra("text", items);
startActivity(intent);
break;
case 5:
intent.putExtra("text", items);
startActivity(intent);
break;
}
}
what i want is show all the strings but in fact the string just show one string. how do i get appropriate string when I click on the list that I want?
thanks a lot.
here’s the logcat :
09-19 12:15:59.889: E/AndroidRuntime(2611): FATAL EXCEPTION: main
09-19 12:15:59.889: E/AndroidRuntime(2611): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wilis.hellotabwidget/com.wilis.hellotabwidget.Tab_Bike_Information_Activity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.os.Handler.dispatchMessage(Handler.java:99)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.os.Looper.loop(Looper.java:130)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.app.ActivityThread.main(ActivityThread.java:3687)
09-19 12:15:59.889: E/AndroidRuntime(2611): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 12:15:59.889: E/AndroidRuntime(2611): at java.lang.reflect.Method.invoke(Method.java:507)
09-19 12:15:59.889: E/AndroidRuntime(2611): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-19 12:15:59.889: E/AndroidRuntime(2611): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-19 12:15:59.889: E/AndroidRuntime(2611): at dalvik.system.NativeStart.main(Native Method)
09-19 12:15:59.889: E/AndroidRuntime(2611): Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.view.ViewGroup.addViewInner(ViewGroup.java:1976)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.view.ViewGroup.addView(ViewGroup.java:1871)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.view.ViewGroup.addView(ViewGroup.java:1828)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.view.ViewGroup.addView(ViewGroup.java:1808)
09-19 12:15:59.889: E/AndroidRuntime(2611): at com.wilis.hellotabwidget.Tab_Bike_Information_Activity.onCreate(Tab_Bike_Information_Activity.java:32)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-19 12:15:59.889: E/AndroidRuntime(2611): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
09-19 12:15:59.889: E/AndroidRuntime(2611): ... 11 more
here’s my activity :
public class Tab_Bike_Information_Activity extends Activity {
WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_bike_information);
final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
actionBar.setTitle(getString(R.string.app_name));
int index = getIntent().getIntExtra("text", 0);
mWebView = (WebView) findViewById(R.id.webview);
String temp = "<html><body>" + "<p align=\"justify\">"
+ getString(R.string.xc_info + index) + "</p> " + "</body></html>";
mWebView.loadData(temp, "text/html", "utf-8");
mWebView.addView(mWebView);
}
and it’s my manifest :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wilis.hellotabwidget"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".SplashScreen_Activity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Home_Activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".Home"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".Tab_Bike_Activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".Tab_Bike_Information_Activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".Tab_Shop_Repair_ListView_Activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".ListViewActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".Tab_Brand_ListView_Activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".BikeType_ListView_Activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".search_activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".Tab_Information_Activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".coba_activity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity
android:name=".Home_Gridview"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
</activity>
</application>
Write below Code line in all case statement and only change String Name in
R.string.xc_info.instead of