My main.xml has two parts. In the left is a listview and in the right is a webView. How can I display the String
String[] myList = new String[]{"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
in the list view
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:id="@+id/mylist"/>
I don't want to use ListActivity. My code is like
package com.android.WebViewChart;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class WebViewChartActivity extends Activity {
/** Called when the activity is first created. */
String[] myList = new String[]{"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView wv = (WebView) findViewById(R.id.WebViewChart);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl("file:///android_asset/1.html");
ListView list = (ListView) findViewById(R.id.mylist);
list.setAdapter(new ArrayAdapter<String>(this, R.id.mylist, myList));
}
}
This deesn't work. Could someone tell me why? Thanks!