So what I'm trying to do is to refresh my webView using a button in the actionbar, the problem? Well, it is easier to explain with some code.
This is at the bottom of my MainActivity.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final String url=getArguments().getString("url");
View rootView = inflater.inflate(R.layout.fragment_main_dummy,container, false);
WebView wv = (WebView)rootView.findViewById(R.id.webView);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl("http://feedit.themeister.se/app/"+url+".php");
wv.setWebViewClient(new WebViewClient());
return rootView;
}
And in order to refresh the webView I need the "url" string but the string is created inside the onCreateView, above that I have this one to actually make the refresh-button work
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_refresh:
// Here should some code be placed but I don't know what to place
return true;
default:
return super.onOptionsItemSelected(item);
}
}
I can't use the url string or the "wv" for webView. Anyone know how I should make this work?
Thanks in advance!