-
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 #483 from pengtianzhu/master
- Loading branch information
Showing
4 changed files
with
128 additions
and
6 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903217/1414080903217ptz.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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<po> | ||
<p1> | ||
my name is peng tianzhu | ||
</p1> | ||
</po> |
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
71 changes: 71 additions & 0 deletions
71
...rc/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903217/Net1414080903217_xml.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,71 @@ | ||
package edu.hzuapps.androidlabs.homeworks.net1414080903217; | ||
|
||
import android.os.Handler; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
import org.jsoup.select.Elements; | ||
import java.io.IOException; | ||
|
||
public class Net1414080903217_xml extends AppCompatActivity { | ||
|
||
private Handler handler=null; | ||
private TextView textView=null; | ||
private String cont=""; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.get_xml_net1414080903217); | ||
handler=new Handler(); | ||
|
||
Button button = (Button) this.findViewById(R.id.btn_1); | ||
textView = (TextView) this.findViewById(R.id.content); | ||
} | ||
|
||
public void Click(View v) { | ||
|
||
new Thread(){ | ||
public void run(){ | ||
try { | ||
Document doc = Jsoup.connect("https://github.com/pengtianzhu/android-labs-2017/blob/master/1414080903217.xml").get(); | ||
int i = 1; | ||
Elements data = doc.select("#LC"+i); | ||
while(!data.isEmpty()){ | ||
cont += data.text(); | ||
i++; | ||
data = doc.select("#LC"+i); | ||
} | ||
|
||
Log.d("test",cont); | ||
|
||
}catch(IOException e){ | ||
System.out.println("" + e); | ||
} | ||
|
||
handler.post(runnableUi); | ||
} | ||
}.start(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
Runnable runnableUi=new Runnable(){ | ||
@Override | ||
public void run() { | ||
textView.setText(cont); | ||
|
||
} | ||
|
||
}; | ||
|
||
|
||
|
||
|
||
} |
30 changes: 30 additions & 0 deletions
30
AndroidLabs/app/src/main/res/layout/xml_net1414080903217.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,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
tools:context="edu.hzuapps.androidlabs.homeworks.net1414080903217.Net1414080903217_xml"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/content"/> | ||
|
||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/btn_1" | ||
android:text="获取" | ||
|
||
|
||
android:textSize="18sp" | ||
android:layout_below="@+id/content" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="46dp" | ||
android:onClick="Click" /> | ||
|
||
</RelativeLayout> |