Skip to content

Commit

Permalink
Merge pull request #1825 from odysseyh/master
Browse files Browse the repository at this point in the history
#5 #1823 第5次试验(补交)
  • Loading branch information
zengsn authored May 9, 2019
2 parents 6a640a0 + 7d87adc commit 20508eb
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package edu.hzuapps.androidlabs.com1714080901121signinapp;

import java.io.FileInputStream;
import java.io.FileOutputStream;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Com1714080901121FirstActivity extends Activity implements OnClickListener {
private EditText et_info;
private Button btn_save;
private Button btn_read;

@SuppressLint("CutPasteId")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.com1714080901121homepage);
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 OnClickListener {
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(Com1714080901121FirstActivity.this, "数据保存成功", 0).show();
break;
case R.id.btn_read:
String content = "";
try {
FileInputStream fis = openFileInput("data.txt");
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
content = new String(buffer);
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(Com1714080901121FirstActivity.this, "保存的数据是" + content, 0)
.show();
break;
default:
break;
}
}
}

public void read(View view) {

}

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<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"
android:background="@drawable/green"
tools:context=".Com1714080901121FirstActivity" >

<TextView
android:id="@+id/title"
android:layout_width="198dp"
android:layout_height="38dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="100dp"
android:layout_marginTop="103dp"
android:text="运动健身打卡系统"
android:textColor="#000000"
android:textSize="24dp" />

<TextView
android:id="@+id/textView1"
android:layout_width="288dp"
android:layout_height="102dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="80dp"
android:layout_marginTop="167dp"
android:text="请输入您要打卡的时间:"
android:textColor="#000000"
android:textSize="30dp" />

<Button
android:id="@+id/btn_read"
android:layout_width="143dp"
android:layout_height="68dp"
android:layout_below="@+id/et_info"
android:layout_alignRight="@+id/et_info"
android:layout_marginTop="77dp"
android:layout_marginRight="17dp"
android:background="@drawable/blue"
android:onClick="read"
android:text="读取信息"
android:textColor="#ffffff"
android:textSize="30dp" />

<Button
android:id="@+id/btn_save"
android:layout_width="wrap_content"
android:layout_height="67dp"
android:layout_below="@+id/et_info"
android:layout_alignParentLeft="true"
android:layout_marginLeft="219dp"
android:layout_marginTop="76dp"
android:background="@drawable/blue"
android:text="保存信息"
android:textColor="#ffffff"
android:textSize="30dp" />

<EditText
android:id="@+id/et_info"
android:layout_width="146dp"
android:layout_height="47dp"
android:layout_below="@+id/textView1"
android:layout_alignParentLeft="true"
android:layout_marginLeft="78dp"
android:layout_marginTop="-49dp"
android:ems="10">

<requestFocus />
</EditText>
</RelativeLayout>

0 comments on commit 20508eb

Please sign in to comment.