I set up sliding tabs with two Fragment
s each Fragment
has a Button
which goes to a WebView
. The problem with this is when the WebView
Button
is clicked the sliding tabs are still activated and when a user tries to navigate within the WebView
you end up swiping to the other tab. Is there a way in an on click method to disable the swiping ability of the tabs? Any help would be hugely appreciated!
Here the code:
public class MyWebViewClass extends Fragment {
private WebView mWebView;
private Button mButton;
public MyWebViewClass() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_webview, container, false);
mWebView = (WebView) view.findViewById(R.id.WebView);
mButton = (Button) view.findViewById(R.id.Button1);
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mWebView.setVisibility(View.VISIBLE);
mButton.setVisibility(View.GONE);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("www.google.com");
}
});
return view;
}
bool onTouch(params) {if(someFlagThatMeansThatSlidingIsDissable) { return false; } return super.onTouch(params)}
add some getter and setter for this flag ... then use setter to dissable/enable sliding .... sounds pretty easy (but of course i will not write the code for you - well because it is almost aready written in this comment) ... edit: as i wrote before, problem is when to enable it again? – Allbee