我正在尝试从listview项目上的assets文件夹加载html文件。
问题是,点击它会显示干净的页面,检查html文件。
这是一段代码。
public static ListView listview;
public static ArrayList interviews;
public static ArrayAdapter adapter;
public WebView myWebView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_kochergin);
listview = (ListView) findViewById(R.id.mainListView);
myWebView = (WebView)findViewById(R.id.webview);
// myWebView = new WebView(this);
listview.setBackgroundColor(Color.BLACK);
listview.setCacheColorHint(Color.BLACK);
String[] interviewlist = new String[] {"Interview1", "Interview2","Interview3","Interview4","Interview5","Interview6"};
ArrayList interviews = new ArrayList();
interviews.addAll( Arrays.asList(interviewlist) );
ArrayAdapter adapter = new ArrayAdapter(this, R.layout.simplerow, R.id.rowTextView, interviews);
listview.setAdapter(adapter);
Collections.sort(interviews);
listview.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3)
{
setContentView(R.layout.webview);
// myWebView.setVisibility(View.VISIBLE);
// myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("file:///android_asset/2.html");
}
});
我做错了什么?