Back to project page Gamers.ba-Mobile-app.
The source code is released under:
GNU General Public License
If you think the Android project Gamers.ba-Mobile-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ba.gamers.www.gamers; /*w w w . j a va2s. c o m*/ import android.content.Context; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Display; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.WindowManager; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; public class MyActivity extends ActionBarActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.my, menu); return super.onCreateOptionsMenu(menu); } private WebView webView; @Override protected void onCreate(Bundle savedInstanceState) { //WebView WebView = new WebView(this); super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_my); webView = (WebView) findViewById(R.id.webview); webView.setInitialScale(1); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setBuiltInZoomControls(true); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setScrollbarFadingEnabled(false); webView.loadUrl("http://www.gamers.ba"); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); } //** /** Called when the user touches the button */ public boolean homePage(MenuItem item) { // Do something in response to button click setContentView(R.layout.activity_my); webView = (WebView) findViewById(R.id.webview); getActionBar().setDisplayHomeAsUpEnabled(true); webView.setInitialScale(1); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setBuiltInZoomControls(true); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setScrollbarFadingEnabled(false); webView.loadUrl("http://www.gamers.ba"); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); return false; } public boolean reloadPage (MenuItem item) { setContentView(R.layout.activity_my); String webUrl = webView.getUrl(); webView = (WebView) findViewById(R.id.webview); getActionBar().setDisplayHomeAsUpEnabled(true); webView.setInitialScale(1); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setBuiltInZoomControls(true); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setScrollbarFadingEnabled(false); webView.loadUrl(webUrl); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); return false; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(event.getAction() == KeyEvent.ACTION_DOWN){ switch(keyCode) { case KeyEvent.KEYCODE_BACK: if(webView.canGoBack()){ webView.goBack(); }else{ finish(); } return true; } } return super.onKeyDown(keyCode, event); } }