-
Notifications
You must be signed in to change notification settings - Fork 229
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 #1202 from yingbabywhen/master
#5 提交实验五代码
- Loading branch information
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
students/soft1714080902309/实验五/app/src/main/AndroidManifest.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,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="edu.hzuapps.androidlabs.soft1714080902309"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".Soft1714080902309Activity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
</manifest> |
72 changes: 72 additions & 0 deletions
72
...pp/src/main/java/edu/hzuapps/androidlabs/soft1714080902309/Soft1714080902309Activity.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,72 @@ | ||
package edu.hzuapps.androidlabs.soft1714080902309; | ||
|
||
import android.content.Context; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
|
||
public class Soft1714080902309Activity extends AppCompatActivity { | ||
|
||
private EditText et_info; | ||
private Button btn_save; | ||
private Button btn_read; | ||
|
||
@Override | ||
protected void onCreate(final Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.soft_1714080902309_activity); | ||
//获取布局文件中的控件 | ||
et_info = (EditText) findViewById(R.id.et_info); | ||
btn_save = (Button) findViewById(R.id.btn_save); | ||
btn_read = (Button) findViewById(R.id.btn_read); | ||
//设置按钮点击函数 | ||
btn_save.setOnClickListener(new ButtonListener()); | ||
btn_read.setOnClickListener(new ButtonListener()); | ||
} | ||
|
||
//定义Button按钮点击事件 | ||
private class ButtonListener implements View.OnClickListener { | ||
@Override | ||
public void onClick(View v) { | ||
switch (v.getId()){ | ||
case R.id.btn_save: | ||
String saveinfo = et_info.getText().toString().trim(); | ||
FileOutputStream fileOutputStream; | ||
try { | ||
fileOutputStream=openFileOutput("data.txt", Context.MODE_APPEND); | ||
fileOutputStream.write(saveinfo.getBytes()); | ||
fileOutputStream.close(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
Toast.makeText(Soft1714080902309Activity.this,"谢谢您的建议!",Toast.LENGTH_SHORT).show(); | ||
break; | ||
|
||
case R.id.btn_read: | ||
String content=""; | ||
try{ | ||
FileInputStream fileInputStream=openFileInput("data.txt"); | ||
byte[] buffer=new byte[fileInputStream.available()]; | ||
fileInputStream.read(buffer); | ||
content=new String(buffer); | ||
fileInputStream.close(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
Toast.makeText(Soft1714080902309Activity.this,"您提的建议我们已经采纳:"+content,Toast.LENGTH_SHORT).show(); | ||
break; | ||
|
||
|
||
default: break; | ||
} | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
students/soft1714080902309/实验五/app/src/main/res/layout/soft_1714080902309_activity.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,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout 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=".Soft1714080902309Activity"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="49dp" | ||
android:text="建议反馈" | ||
android:textSize="25dp" | ||
android:gravity="center"/> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="45dp" | ||
android:layout_marginTop="80dp" | ||
android:gravity="left" | ||
android:text="请在下方填写您宝贵的建议:" | ||
android:textSize="20dp" /> | ||
|
||
<EditText | ||
android:id="@+id/et_info" | ||
android:layout_width="match_parent" | ||
android:layout_height="200dp" | ||
android:layout_marginTop="130dp" | ||
android:maxHeight="80dp" | ||
android:textColor="#009688" | ||
android:background="@drawable/white"/> | ||
|
||
|
||
<Button | ||
android:id="@+id/btn_save" | ||
android:layout_width="wrap_content" | ||
android:layout_height="50dp" | ||
android:layout_marginTop="400dp" | ||
android:textSize="20dp" | ||
android:text="提交建议"/> | ||
|
||
<Button | ||
android:id="@+id/btn_read" | ||
android:layout_width="wrap_content" | ||
android:layout_height="50dp" | ||
android:layout_marginLeft="150dp" | ||
android:layout_marginTop="400dp" | ||
android:textSize="20dp" | ||
android:text="查看我提交的建议"/> | ||
|
||
|
||
|
||
</RelativeLayout> |
3 changes: 3 additions & 0 deletions
3
students/soft1714080902309/实验五/app/src/main/res/values/strings.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,3 @@ | ||
<resources> | ||
<string name="app_name">BookReading</string> | ||
</resources> |