Skip to content

Commit

Permalink
Merge pull request #471 from Lee20170303/master
Browse files Browse the repository at this point in the history
#6 #146 第六次作业
  • Loading branch information
zengsn authored Jun 16, 2017
2 parents 6733b35 + 57cd4d5 commit 11ad692
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="10dp"
android:padding="10dp"
tools:context="com.example.hzu.myapplication.Net1414080903235_network">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/netAddress"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/openNetAddress"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="0"
android:text="Open"
android:textAllCaps="false"/>
</LinearLayout>

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

</LinearLayout>

0 comments on commit 11ad692

Please sign in to comment.