Skip to content

Commit

Permalink
Add ActionBar to WebView activity
Browse files Browse the repository at this point in the history
  • Loading branch information
viren-nadkarni committed May 26, 2017
1 parent 48010fd commit 02bdc33
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
applicationId "com.appknox.mfva"
minSdkVersion 19
targetSdkVersion 25
versionCode 5
versionCode 6
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</activity>
<activity
android:name=".WebViewActivity"
android:label="@string/activity_title_webview"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait" />
<activity
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/com/appknox/mfva/WebViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.webkit.WebView;

/**
* Created by viren on 23/5/17.
*/

public class WebViewActivity extends Activity {
public class WebViewActivity extends AppCompatActivity {
private WebView webView;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);

webView = (WebView) findViewById(R.id.webView);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_api_requests);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

webView = (WebView) findViewById(R.id.activity_webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://example.com");
}
Expand Down
28 changes: 25 additions & 3 deletions app/src/main/res/layout/activity_webview.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView"
<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"/>
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.appknox.mfva.WebViewActivity">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_api_requests"
android:background="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:theme="@style/AppTheme"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
app:popupTheme="@style/Theme.AppCompat.NoActionBar" />

<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<string name="activity_title_main">MFVA</string>
<string name="activity_title_api_requests">API Requests</string>
<string name="activity_title_webview">WebView</string>

<string name="action_about">About</string>

Expand Down

0 comments on commit 02bdc33

Please sign in to comment.