-
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 #1500 from lveking/master
- Loading branch information
Showing
10 changed files
with
185 additions
and
85 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
73 changes: 73 additions & 0 deletions
73
...4080902114/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902114/Main2Activity.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,73 @@ | ||
package edu.hzuapps.androidlabs.soft1714080902114; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.app.Activity; | ||
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 Main2Activity extends AppCompatActivity { | ||
private EditText et_info; | ||
private Button btn_save; | ||
private Button btn_read; | ||
|
||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main2); | ||
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()); | ||
} | ||
private class ButtonListener implements View.OnClickListener { | ||
@SuppressLint("WrongConstant") | ||
public void onClick(View v) { | ||
switch(v.getId()){ | ||
case R.id.btn_save: | ||
String saveinfo=et_info.getText().toString().trim(); | ||
FileOutputStream fos; | ||
try{ | ||
fos=openFileOutput("data.txt", Context.MODE_APPEND); | ||
fos.write(saveinfo.getBytes()); | ||
fos.close(); | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
Toast.makeText(Main2Activity.this,"笔记保存成功",0).show(); | ||
break; | ||
case R.id.btn_read: | ||
String content=""; | ||
try{ | ||
FileInputStream fis=openFileInput("data.txt"); | ||
byte[] buffer=new byte[((FileInputStream) fis).available()]; | ||
fis.read(buffer); | ||
content=new String(buffer); | ||
fis.close(); | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
Toast.makeText(Main2Activity.this,"保存的笔记是:"+content,0).show(); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
|
35 changes: 34 additions & 1 deletion
35
...14080902114/app/src/main/java/edu/hzuapps/androidlabs/soft1714080902114/MainActivity.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 |
---|---|---|
@@ -1,13 +1,46 @@ | ||
package edu.hzuapps.androidlabs.soft1714080902114; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
Button button1 = (Button) findViewById(R.id.button_1); | ||
button1.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(MainActivity.this, Main2Activity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
|
||
Button button2 = (Button) findViewById(R.id.button_2); | ||
button2.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(MainActivity.this, Main2Activity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
|
||
|
||
Button button3 = (Button) findViewById(R.id.button_3); | ||
button3.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(MainActivity.this, Main2Activity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
|
||
|
||
} | ||
} | ||
|
47 changes: 0 additions & 47 deletions
47
...pp/src/main/java/edu/hzuapps/androidlabs/soft1714080902114/Soft1714080902114Activity.java
This file was deleted.
Oops, something went wrong.
Binary file not shown.
25 changes: 17 additions & 8 deletions
25
students/soft1714080902114/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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<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" | ||
tools:context=".MainActivity" | ||
android:background="@drawable/img"> | ||
android:orientation="vertical" > | ||
|
||
<ImageView | ||
android:id="@+id/img" | ||
<Button | ||
android:id="@+id/button_1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:src="@drawable/img" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
android:text="新建笔记"/> | ||
<Button | ||
android:id="@+id/button_2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="读取记录"/> | ||
<Button | ||
android:id="@+id/button_3" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="清楚记录"/> | ||
|
||
|
||
</android.support.constraint.ConstraintLayout> | ||
</LinearLayout> |
42 changes: 42 additions & 0 deletions
42
students/soft1714080902114/app/src/main/res/layout/activity_main2.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,42 @@ | ||
<?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" | ||
tools:context=".Main2Activity"> | ||
|
||
|
||
|
||
<TextView | ||
android:id="@+id/textView1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentTop="true" | ||
android:textSize="20dp" | ||
android:text="请输入你要保存的笔记:"/> | ||
|
||
<EditText | ||
android:id="@+id/et_info" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentLeft="true" | ||
android:layout_below="@+id/textView1" | ||
android:ems="10" > | ||
<requestFocus /> | ||
</EditText> | ||
<Button | ||
android:id="@+id/btn_read" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignRight="@+id/et_info" | ||
android:layout_below="@+id/et_info" | ||
android:text="查看笔记"/> | ||
<Button | ||
android:id="@+id/btn_save" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/et_info" | ||
android:text="保存笔记"/> | ||
|
||
</RelativeLayout> |
27 changes: 0 additions & 27 deletions
27
students/soft1714080902114/app/src/main/res/layout/soft_1714080902114_activity.xml
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
students/soft1714080902114/app/src/main/res/values/colors.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"?> | ||
<resources> | ||
<color name="colorPrimary">#008577</color> | ||
<color name="colorPrimaryDark">#00574B</color> | ||
<color name="colorAccent">#D81B60</color> | ||
</resources> |
11 changes: 11 additions & 0 deletions
11
students/soft1714080902114/app/src/main/res/values/styles.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,11 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |