Hello, everyone I'm a beginner who's studying applications for the first time
I came all the way here with the help of the hash code, but it's stuck here again, so This is an implementation of an extended list view in the main activity so that you can click on the child list view to get a web view
MainActivity.java
mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
switch (groupPosition) {
case 0:
switch (childPosition) {
case 0:
Menu.setVisibility(View.GONE);
menu01Activity fragment = new menu01Activity();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
break;
case 1:
Menu.setVisibility(View.GONE);
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container, menu03Activity.newInstance("http://m.naver.com"))
.addToBackStack(null)
.commit();
break;
menu03Activity.java
public class menu03Activity extends android.support.v4.app.Fragment {
WebView mWebView;
private static final String URL = "url";
public static Fragment newInstance(String url) {
Fragment fragment = new menu03Activity();
Bundle args = new Bundle();
args.putString(URL, url);
fragment.setArguments(args);
return fragment;
}
public menu03Activity(){
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saveInstanceState){
View rootView = inflater.inflate(R.layout.activity_menu03, container, false);
WebView webView = new WebView(getActivity());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(getArguments().getString(URL));
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new WebViewClient());
return webView;
}
}
I implemented a web view in the fragment like this, but when I press Back in the web view, it immediately goes to the home screen.crying I'm so curious about how to apply Back in the Web view. Please help me ㅠ<
back-button webview
//Go to the previous screen if you can go back
if(webView.canGoBack()){
webView.goBack();
}
There is an answer to a question that someone asked before. Please refer to it
http://tkddlf4209.blog.me/220689558225?Redirect=Log&from=postView
© 2024 OneMinuteCode. All rights reserved.