I want to call the class "Market", which describes the webview. It should be done "onclick" when clicking on scrollable menu. But after I click the button my app just crashes, and I have no idea what to do now.
Main Activity:
switch (item.getItemId()) {
case R.id.item1:
//your action
break;
case R.id.item2:
//your action
break;
case R.id.item3:
//your action
break;
case R.id.item4:
//your action
setContentView(R.layout.market_activity);
market.setthepage();
break;
case R.id.item5:
//your action
break;
Market Class:
public class Market extends AppCompatActivity {
WebView wb;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public void setthepage(){
wb = (WebView) findViewById(R.id.web_market);
wb.getSettings().setJavaScriptEnabled(true);
wb.loadUrl("https://www.pepper.pl/");
}
@Override
public void onBackPressed() {
if (wb.canGoBack()){
wb.goBack();
}else{
super.onBackPressed();
}
}}
.. and a simple webview.
I was trying using intend, context etc. but am probably using it wrong. Can you help me with my problem?
Thank you in advance, Milo