-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #471 from Lee20170303/master
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...ain/java/edu/hzuapps/androidlabs/homeworks/net1414080903235/Net1414080903235_network.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
.../edu/hzuapps/androidlabs/homeworks/net1414080903235/activity_net1414080903235_network.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |