From 57cd4d5b1c9c439431dca5e2efd8cec6af9bf64a Mon Sep 17 00:00:00 2001 From: Lee20170303 <1805407781@qq.com> Date: Fri, 16 Jun 2017 16:43:19 +0800 Subject: [PATCH] =?UTF-8?q?#6=20#146=20=E7=AC=AC=E5=85=AD=E6=AC=A1?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Net1414080903235_network.java | 44 +++++++++++++++++++ .../activity_net1414080903235_network.xml | 35 +++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/Net1414080903235_network.java create mode 100644 AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/activity_net1414080903235_network.xml diff --git a/AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/Net1414080903235_network.java b/AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/Net1414080903235_network.java new file mode 100644 index 00000000..34b50ae1 --- /dev/null +++ b/AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/Net1414080903235_network.java @@ -0,0 +1,44 @@ +package edu.hzuapps.androidlabs.homeworks.net1414080903235; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.webkit.WebView; +import android.webkit.WebViewClient; +import android.widget.Button; +import android.widget.EditText; + +public class Net1414080903235_network extends AppCompatActivity { + + private WebView myWebView; + private EditText networkAddr; + private Button openNetwork; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_net1414080903235_network); + + networkAddr = (EditText)findViewById(R.id.netAddress); + myWebView = (WebView)findViewById(R.id.webView); + + openNetwork = (Button)findViewById(R.id.openNetAddress); + openNetwork.setOnClickListener(new myOnClickListener()); + } + + class myOnClickListener implements View.OnClickListener { + @Override + public void onClick(View view) { + myWebView.getSettings().setJavaScriptEnabled(true); + myWebView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + view.loadUrl(url); + return true; + } + }); + String networkAddress = networkAddr.getText().toString(); + myWebView.loadUrl("http://"+networkAddress); + } + } +} \ No newline at end of file diff --git a/AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/activity_net1414080903235_network.xml b/AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/activity_net1414080903235_network.xml new file mode 100644 index 00000000..a7776e4d --- /dev/null +++ b/AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/activity_net1414080903235_network.xml @@ -0,0 +1,35 @@ + + + + + + +