How To Make Web Application

By Unknown - Februari 20, 2018



Hallo people today we will make web application before we make this application read this blog for begining     ,ok after read that articel we will go to make web application, let's goπŸ‘ŠπŸ‘ŠπŸ‘ŠπŸ‘Š.



First open your android studio and make a new project and choose empty activity.
don't forget to install the butter knife in android studio


and add this code in build gradle:
compile 'com.jakewharton:butterknife:8.8.1'compile 'com.android.support:appcompat-v7:26.+'

Second open the activity_main.xml and make the code like this:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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="com.blogspot.ammar.jalantikus.TechNewsActivity">

    <ProgressBar        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:id="@+id/pgweb"        style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"/>



    <WebView        android:layout_width="match_parent"        android:layout_height="match_parent"        android:id="@+id/webView"        android:layout_below="@+id/pgweb" />

</RelativeLayout>




third is open the MainActivity.java then make code like this for make the action to active the web application:
 
package com.blogspot.ammar.jalantikus;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TechNewsActivity extends AppCompatActivity {

    @BindView(R.id.pgweb)
    ProgressBar pgweb;
    @BindView(R.id.webView)
    WebView webView;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tech_news);
        ButterKnife.bind(this);pengaturanWebView();

        String google = "https://techcrunch.com/";
        webView.loadUrl(google);
        webView.setWebViewClient(new TechNewsActivity.Clientweb());
    }
    private void pengaturanWebView() {
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setSupportZoom(true);
        webView.setWebChromeClient(new WebChromeClient(){
            @Override            public void onProgressChanged(WebView view, int newProgress) {
                //untuk mengubah progres bar menjadi visible                pgweb.setVisibility(View.VISIBLE);
                //menampilkan loading                pgweb.setProgress(newProgress);
                //jika loading sampai 100% sembunyikan                if (newProgress == 100) {
                    pgweb.setVisibility(view.INVISIBLE);
                }
            }
        });
    }

    private class Clientweb extends WebViewClient {

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




Ok maybe that all for me dont forget to follow this blog bye.

  • Share:

You Might Also Like

0 komentar