From dc717deefe4d5b42aa8d66ee8ecfd02b27c10ebc Mon Sep 17 00:00:00 2001 From: wufchun <1462803989@qq.com> Date: Mon, 8 Apr 2019 19:50:30 +0800 Subject: [PATCH] =?UTF-8?q?#5=20#788=20=E7=AC=AC5=E6=AC=A1=E5=AE=9E?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/src/main/AndroidManifest.xml | 5 +- .../soft1714080902414/Soft1714080902414.java | 63 +++++++ .../Soft1714080902414Activity.java | 28 --- .../Soft1714080902414Activity2.java | 13 -- .../res/drawable/ic_launcher_background.xml | 170 ------------------ .../app/src/main/res/layout/activity_main.xml | 40 +++++ .../layout/activity_soft17140809024142.xml | 69 ------- .../layout/soft_1714080902414_activity.xml | 46 ----- .../app/src/main/res/values/colors.xml | 4 +- .../app/src/main/res/values/strings.xml | 12 +- 10 files changed, 108 insertions(+), 342 deletions(-) create mode 100644 students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414.java delete mode 100644 students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity.java delete mode 100644 students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity2.java delete mode 100644 students/soft1714080902414/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 students/soft1714080902414/app/src/main/res/layout/activity_main.xml delete mode 100644 students/soft1714080902414/app/src/main/res/layout/activity_soft17140809024142.xml delete mode 100644 students/soft1714080902414/app/src/main/res/layout/soft_1714080902414_activity.xml diff --git a/students/soft1714080902414/app/src/main/AndroidManifest.xml b/students/soft1714080902414/app/src/main/AndroidManifest.xml index 6d87bcab9..6a47d2d3c 100644 --- a/students/soft1714080902414/app/src/main/AndroidManifest.xml +++ b/students/soft1714080902414/app/src/main/AndroidManifest.xml @@ -9,13 +9,12 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - - + - + diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414.java new file mode 100644 index 000000000..6a2247574 --- /dev/null +++ b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414.java @@ -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; + } + } +} diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity.java deleted file mode 100644 index b266567c3..000000000 --- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity.java +++ /dev/null @@ -1,28 +0,0 @@ -package edu.hzuapps.androidlabs.soft1714080902414; - -import android.content.Intent; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -public class Soft1714080902414Activity extends AppCompatActivity implements View.OnClickListener { - - private Button button; - private Button button1; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.soft_1714080902414_activity); - button=(Button)findViewById(R.id.button); - button1=(Button)findViewById(R.id.button1); - button.setOnClickListener(this); - } - @Override - public void onClick(View v) { - Intent intent =new Intent(Soft1714080902414Activity.this,Soft1714080902414Activity2.class); - startActivity(intent); - } - - -} diff --git a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity2.java b/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity2.java deleted file mode 100644 index f0aa9c9f3..000000000 --- a/students/soft1714080902414/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902414/Soft1714080902414Activity2.java +++ /dev/null @@ -1,13 +0,0 @@ -package edu.hzuapps.androidlabs.soft1714080902414; - -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; - -public class Soft1714080902414Activity2 extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_soft17140809024142); - } -} diff --git a/students/soft1714080902414/app/src/main/res/drawable/ic_launcher_background.xml b/students/soft1714080902414/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 0d025f9bf..000000000 --- a/students/soft1714080902414/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/students/soft1714080902414/app/src/main/res/layout/activity_main.xml b/students/soft1714080902414/app/src/main/res/layout/activity_main.xml new file mode 100644 index 000000000..20b661928 --- /dev/null +++ b/students/soft1714080902414/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,40 @@ + + + + +