Skip to content

Commit

Permalink
Merge pull request #1500 from lveking/master
Browse files Browse the repository at this point in the history
#5 #460 第5次实验
  • Loading branch information
zengsn authored Apr 19, 2019
2 parents 44feca2 + c5966b9 commit 5207bdb
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 85 deletions.
4 changes: 2 additions & 2 deletions students/soft1714080902114/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Soft1714080902114Activity">
<activity android:name=".Main2Activity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"></activity>
</application>

</manifest>
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;
}
}
}


}


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);
}
});


}
}

This file was deleted.

Binary file not shown.
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>
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>

This file was deleted.

6 changes: 6 additions & 0 deletions students/soft1714080902114/app/src/main/res/values/colors.xml
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 students/soft1714080902114/app/src/main/res/values/styles.xml
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>

0 comments on commit 5207bdb

Please sign in to comment.