I have similar problem like the one in the link below.!
passing url and title to a webview in android
I have a code like this in the MainActivity:
ListView lv;
Arrayadapter<String>aa;
String items[]={"item1","item2"};
@Override
protected void onCreate(Bundle Savedinstancestate){
super.onCreate(Savedinstancestate);
lv=(ListView)findViewById(R.id.listView1);
aa=new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_dropdown_item_1line,items) ;
lv.setAdapter(aa);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
Intent newActivity0 = new Intent(MainActivity.this, Mywebpage.class);
newActivity0.putExtra("title", str[position]);
switch (position) {
case 0:
newActivity0.putExtra("url", "http://www.google.com");
break;
case 1:
newActivity0.putExtra("url", "file:///android_asset/item1.html");
break;
case 2:
newActivity0.putExtra("url", "file://android_asset/item2.html");
break;
}
and in Mypage
class get intent is like
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webviewpage);
Bundle extras = getIntent().getExtras();
String title, url;
if (extras != null) {
title = extras.getString("title");
url = extras.getString("url");
WebView wbView = (WebView) findViewById(R.id.WebView);
wbView.getSettings().setJavaScriptEnabled(true);
wbView.loadUrl(url);
//WbView.setWebViewClient(new myWebViewClient()); }
And have tried with and without setting webview clients(the line which I have commented towards end, with a corresponding class).
I am getting Runtime NULLPOINTER Exception when I try to click on the item.