Skip to content

Commit

Permalink
hzuapps#6 hzuapps#881 第六次实验
Browse files Browse the repository at this point in the history
  • Loading branch information
1614080902117 committed May 26, 2018
1 parent 0471a9d commit a040e37
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 48 deletions.
3 changes: 2 additions & 1 deletion soft1614080902117/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Soft1614080902117Activity1"></activity>
<activity android:name=".Soft1614080902117Activity1" />
<activity android:name=".Soft1614080902117Activity2" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
package edu.hzuapps.androidlabs.soft1614080902117;

import android.app.Activity;
import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.ArrayAdapter;
import android.widget.Button;
import android.app.Activity;

import android.widget.ListView;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.String;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Soft1614080902117Activity extends Activity {
String[] adapterData;
Expand All @@ -39,6 +34,14 @@ public void onClick(View v) {
thisActivity.startActivity(intent);
}
});
Button btnDlow = (Button)findViewById(R.id.button8);
btnDlow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(thisActivity,Soft1614080902117Activity2.class);
thisActivity.startActivity(intent);
}
});
}
public String load(){ //读取文件
FileInputStream in =null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package edu.hzuapps.androidlabs.soft1614080902117;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class Soft1614080902117Activity2 extends Activity {
private EditText editText;
private Button button;
private ImageView imageView;
private Bitmap bitmap;
Handler handler=new Handler(){
public void handleMessage(Message msg) {
if(msg.what==111){
imageView.setImageBitmap(bitmap);
}
};
};
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_soft16140809021172);
editText=(EditText) findViewById(R.id.editweb);
button=(Button) findViewById(R.id.button7);
imageView=(ImageView) findViewById(R.id.imageView);
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
new Thread(t).start();
}
});
}
Thread t=new Thread(){
public void run() {
String iPath=editText.getText().toString();
try {
URL url=new URL(iPath);
InputStream inputStream=url.openStream();
bitmap=BitmapFactory.decodeStream(inputStream);
handler.sendEmptyMessage(111);
inputStream.close();
inputStream=url.openStream();
File file=new File(Environment.getExternalStorageDirectory()+"/DCIM/");
FileOutputStream fileOutputStream=new FileOutputStream(file);
int hasRead=0;
while((hasRead=inputStream.read())!=-1){
fileOutputStream.write(hasRead);
}
fileOutputStream.close();
inputStream.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
};
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@

</SearchView>

<ListView
android:layout_width="346dp"
android:layout_height="426dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.493" />
<TextView
android:id="@+id/textView"
android:layout_width="363dp"
Expand All @@ -58,6 +44,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintVertical_bias="0.516" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
Expand All @@ -72,24 +59,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.781"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/button2"
app:layout_constraintVertical_bias="1.0" />

<Button
android:id="@+id/button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="68dp"
android:layout_marginRight="8dp"
android:layout_marginStart="68dp"
android:background="@drawable/xinjian"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.026"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintTop_toBottomOf="@+id/button2"
app:layout_constraintVertical_bias="1.0" />

<TextView
Expand All @@ -104,7 +74,7 @@
android:text="新建"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.027"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.997" />
Expand All @@ -113,20 +83,66 @@
android:id="@+id/button2"
android:layout_width="27dp"
android:layout_height="25dp"
android:layout_marginBottom="4dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/shezhi"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.678"
app:layout_constraintStart_toEndOf="@+id/button"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.975" />
app:layout_constraintHorizontal_bias="0.779"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="68dp"
android:layout_marginRight="8dp"
android:layout_marginStart="68dp"
android:background="@drawable/xinjian"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />

<ListView
android:id="@+id/listView"
android:layout_width="346dp"
android:layout_height="404dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="56dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

</ListView>

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下载"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/button8"
android:layout_width="32dp"
android:layout_height="23dp"
android:layout_marginBottom="16dp"
android:background="@android:drawable/arrow_down_float"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent" />


</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".Soft1614080902117Activity2">

<TextView
android:id="@+id/textView8"
android:layout_width="369dp"
android:layout_height="53dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:background="@drawable/background1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.48"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView12"
android:layout_width="65dp"
android:layout_height="22dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:text="网络下载"
app:layout_constraintEnd_toEndOf="@+id/textView8"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView8" />

<EditText
android:id="@+id/editweb"
android:layout_width="279dp"
android:layout_height="wrap_content"

android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView8" />

<Button
android:id="@+id/button7"
android:layout_width="68dp"
android:layout_height="36dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="56dp"
android:background="#dfd9d9"
android:text="下载"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"

app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/imageView"
android:layout_width="352dp"
android:layout_height="408dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />


</android.support.constraint.ConstraintLayout>

0 comments on commit a040e37

Please sign in to comment.