• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

WebView how to show app title

Greum

Well-Known Member
I have a simple web view app which appears to work, but I would like to show the app title bar and I can't figure out how to do do so.

This is my Java

Java:
public class MainActivity extends Activity {

    private WebView webView;

    Activity activity;
    private ProgressDialog progDailog;

    //@SuppressLint("NewApi")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        activity = this;

        progDailog = ProgressDialog.show(activity, "Loading", "Please wait...", true);
        progDailog.setCancelable(false);

        webView = (WebView) findViewById(R.id.simpleWebView);

        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.setWebViewClient(new WebViewClient() {

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                progDailog.show();
                view.loadUrl(url);
                return true;
            }

            @Override
            public void onPageFinished(WebView view, final String url) {
                progDailog.dismiss();
            }
        });

        webView.loadUrl("https://theglastonburytarot.co.uk/");

    }
}

and this is my layout:

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <WebView
        android:id="@+id/simpleWebView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</LinearLayout>
 
Okay, I've figured out the answer. Replacing

Java:
public class MainActivity extends Activity

with

Java:
public class MainActivity extends AppCompatActivity

did the trick!
 
Back
Top Bottom