forked from hzuapps/android-labs-2019
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
108 additions
and
342 deletions.
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
...902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414.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,63 @@ | ||
package edu.hzuapps.androidlabs.soft1714080902414; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
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 Soft1714080902414 extends AppCompatActivity implements View.OnClickListener { | ||
private Button button1; | ||
private Button button2; | ||
private EditText editText1; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
button1=(Button) findViewById(R.id.bt1); | ||
button2=(Button) findViewById(R.id.bt2); | ||
editText1=(EditText) findViewById(R.id.et1); | ||
button1.setOnClickListener(this); | ||
button2.setOnClickListener(this); | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
switch (view.getId()) | ||
{ | ||
case R.id.bt1: String save=editText1.getText().toString().trim(); | ||
FileOutputStream fos; | ||
try{ | ||
fos=openFileOutput("data.txt",MODE_PRIVATE); | ||
fos.write(save.getBytes()); | ||
fos.close(); | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
Toast.makeText( Soft1714080902414.this,"数据保存成功",Toast.LENGTH_SHORT).show(); | ||
break; | ||
case R.id.bt2: String content=""; | ||
try { | ||
FileInputStream fis=openFileInput("data.txt"); | ||
byte[] buffer=new byte[fis.available()]; | ||
fis.read(buffer); | ||
content=new String(buffer); | ||
fis.close(); | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
Toast.makeText(Soft1714080902414.this,"保存的数据为"+content,Toast.LENGTH_SHORT).show(); | ||
break; | ||
} | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
...pp/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...p/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity2.java
This file was deleted.
Oops, something went wrong.
170 changes: 0 additions & 170 deletions
170
students/soft1714080902414/app/src/main/res/drawable/ic_launcher_background.xml
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
students/soft1714080902414/app/src/main/res/layout/activity_main.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,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout 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" | ||
android:orientation="vertical" | ||
android:background="@color/background" | ||
> | ||
<EditText | ||
android:id="@+id/et1" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
|
||
android:text="" | ||
/> | ||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal"> | ||
<Button | ||
android:id="@+id/bt1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="100dp" | ||
android:layout_marginTop="100dp" | ||
android:text="点击按钮保存" | ||
/> | ||
|
||
<Button | ||
android:id="@+id/bt2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="50dp" | ||
android:layout_marginTop="100dp" | ||
android:text="点击按钮查看" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
Oops, something went wrong.