Hi, guys!
Have some problem:
I create simple Activity with webview.
If you visit Facebook Mobile, you will notice that you can scroll to the bottom of the page and when you do, more loads posts - via default browser. But this is not working in my webview.
The other thing that also needs to be fixed is the "More" button on the top right corner. The menu itself works when you touch the "more" button but none of the menu items are clickable in my webview.
Can anyone help me?
code here:
main.xml
Have some problem:
I create simple Activity with webview.
If you visit Facebook Mobile, you will notice that you can scroll to the bottom of the page and when you do, more loads posts - via default browser. But this is not working in my webview.
The other thing that also needs to be fixed is the "More" button on the top right corner. The menu itself works when you touch the "more" button but none of the menu items are clickable in my webview.
Can anyone help me?
code here:
Code:
public class FacebookProjActivity extends Activity {
WebView webview;
public String url = "http://m.facebook.com";
public String oldUrl;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
//String myUserAgent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7";
//webview.getSettings().setUserAgentString(myUserAgent);
webview.getSettings().setSavePassword(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically (true);
webview.getSettings().setAppCacheEnabled(true);
webview.getSettings().setPluginsEnabled(true);
webview.getSettings().setSupportMultipleWindows (true);
webview.getSettings().supportZoom();
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.getSettings().setLightTouchEnabled(true);
webview.setWebViewClient(new FacebookProWebViewClient());
webview.loadUrl("http://m.facebook.com");
}
@Override
protected void onDestroy() {
super.onDestroy();
}
private class FacebookProWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView webview, String url) {
if (webview.getUrl().startsWith("http://m.facebook") == true){
webview.loadUrl(url);
return true;
}else{
return false;
}
}
public void onFormResubmission (WebView webview, Message dontResend, Message resend){
}
public void onLoadResource (WebView webview, String url){
}
}
}
main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>