I have 2 Buttons which load 2 difefrent html sites respectively.
public class Information extends Activity implements OnClickListener {
Button b1, b2 ;
private WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.info);
b1=(Button) findViewById(R.id.b1);
b2=(Button) findViewById(R.id.b2);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
webview=(WebView) findViewById(R.id.webview);
webview.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
}
@Override
public void onClick(View v){
switch(v.getId()) {
case R.id.b1:
showOne();
break;
case R.id.b2:
showTwo();
break;
}
}
public void showOne(){
webview.loadUrl("some url");
}
public void showTwo() {
webview.loadUrl("some url here");
}
}
this results in errors that force the application to end.
When I remove the webview part, the buttons are desplayed, but nothing happens when I click on them.
any ideas?
check that there are a webview named webview in R.layout.info ?
webview=(WebView) findViewById(R.id.webview); complier couldnt find this webview.
and try to add , com.yourpackagename.R;