-
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 #1825 from odysseyh/master
- Loading branch information
Showing
2 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...src/main/java/edu/hzuapps/androidlabs/com1714080901121/Com1714080901121FirstActivity.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,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 | ||
|
||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
students/com1714080901121/app/src/main/res/layout/com1714080901121homepage.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,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> |