Skip to content

Commit

Permalink
Merge pull request #1932 from Android-lgw/master
Browse files Browse the repository at this point in the history
#5 #279 实验五代码
  • Loading branch information
zengsn authored Jun 11, 2019
2 parents 02e33e9 + 48bcc79 commit 4ec6488
Show file tree
Hide file tree
Showing 10 changed files with 522 additions and 0 deletions.
22 changes: 22 additions & 0 deletions students/soft1714080902325/app5/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.hzuapps.androidlabs.soft1714080902325">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".HomeActivity"></activity>
<activity android:name=".CunchuActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package edu.hzuapps.androidlabs.soft1714080902325;

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.FileOutputStream;

public class CunchuActivity extends AppCompatActivity {
private EditText et_info01;
private EditText et_info02;
private Button btn_save;
private Button btn_read;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cunchu);//获取布局文件中的控件
et_info01=(EditText) findViewById(R.id.et_info01);
et_info02=(EditText) findViewById(R.id.et_info02);
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 View.OnClickListener {
public void onClick(View v) {
switch(v.getId()) {
case R.id.btn_save:
String hang="\n";
String saveinfo1=et_info01.getText().toString().trim();
String saveinfo2=et_info02.getText().toString().trim();
FileOutputStream fos;
try {
//保留数据
fos=openFileOutput("data01.txt", Context.MODE_APPEND);
fos.write(hang.getBytes());
fos.write(saveinfo1.getBytes());
fos.write(hang.getBytes());
fos.write(saveinfo2.getBytes());
fos.write(hang.getBytes());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(CunchuActivity.this,"数据保存成功",Toast.LENGTH_SHORT).show();
break;
case R.id.btn_read:
String content="";
try {
//获取保存的数据
FileInputStream fis=openFileInput("data01.txt");
byte[] buffer=new byte[fis.available()];
fis.read(buffer);
content=new String(buffer);
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(CunchuActivity.this,"保存的数据是:"+content,Toast.LENGTH_SHORT).show();
break;
default:
break;
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package edu.hzuapps.androidlabs.soft1714080902325;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import android.widget.Button;

public class HomeActivity extends AppCompatActivity {
private Button button02;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

button02=(Button)findViewById(R.id.button2);
button02.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(HomeActivity.this, CunchuActivity.class);
startActivity(intent);
}
});
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package edu.hzuapps.androidlabs.soft1714080902325;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;


public class MainActivity extends AppCompatActivity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

imageView=(ImageView)findViewById(R.id.main);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(MainActivity.this, HomeActivity.class);
startActivity(intent);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/jishi">

<TextView
android:id="@+id/textView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="13dp"
android:layout_marginLeft="13dp"
android:layout_marginTop="124dp"
android:text="待完成任务:"
android:textSize="22dp" />

<EditText
android:id="@+id/et_info01"
android:layout_width="200dp"
android:layout_height="38dp"
android:layout_alignBottom="@+id/textView01"
android:layout_marginStart="2dp"
android:layout_marginLeft="2dp"
android:layout_marginBottom="-6dp"
android:layout_toEndOf="@+id/textView01"
android:layout_toRightOf="@+id/textView01" />

<TextView
android:id="@+id/textView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="21dp"
android:layout_marginLeft="21dp"
android:layout_marginTop="207dp"
android:text="截至日期:"
android:textSize="22dp" />

<EditText
android:id="@+id/et_info02"
android:layout_width="200dp"
android:layout_height="38dp"
android:layout_alignLeft="@id/textView02"
android:layout_alignBottom="@+id/textView02"
android:layout_marginLeft="130dp"
android:layout_marginBottom="-6dp" />


<Button
android:id="@+id/btn_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="60dp"
android:layout_marginLeft="60dp"
android:layout_marginBottom="137dp"
android:text="添加便签"
android:textSize="22dp"
android:background="@drawable/btn_bg_red"/>

<Button
android:id="@+id/btn_read"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="137dp"
android:text="查看记录"
android:textSize="22dp"
android:background="@drawable/btn_bg_red"/>
</RelativeLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
android:background="@drawable/timg2"
tools:context=".HomeActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|center_horizontal"
android:orientation="vertical"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="-30dp">

<LinearLayout
android:layout_width="420dp"
android:layout_height="120dp"
android:gravity="center"
android:orientation="vertical">

<Button
android:id="@+id/button"
android:layout_width="151dp"
android:layout_height="70dp"
android:background="@drawable/btn_bg_red"
android:textSize="18dp"
android:text="收入与支出" />

</LinearLayout>

<LinearLayout
android:layout_width="420dp"
android:layout_height="120dp"
android:gravity="center"
android:orientation="vertical">

<Button
android:id="@+id/button2"
android:layout_width="151dp"
android:layout_height="70dp"
android:background="@drawable/btn_bg_red"
android:textSize="18dp"
android:text="备忘记事" />
</LinearLayout>

<LinearLayout
android:layout_width="420dp"
android:layout_height="120dp"
android:gravity="center"
android:orientation="vertical">

<Button
android:id="@+id/button3"
android:layout_width="151dp"
android:layout_height="70dp"
android:background="@drawable/btn_bg_red"
android:textSize="18dp"
android:text="计算器" />
</LinearLayout>

</LinearLayout>

</android.support.constraint.ConstraintLayout>
24 changes: 24 additions & 0 deletions students/soft1714080902325/app6/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.hzuapps.androidlabs.soft1714080902325">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MusicActivity"></activity>
<activity android:name=".HomeActivity"></activity>
<activity android:name=".CunchuActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package edu.hzuapps.androidlabs.soft1714080902325;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import android.widget.Button;

public class HomeActivity extends AppCompatActivity {
private Button button01;
private Button button02;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

button01=(Button)findViewById(R.id.button1);
button01.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(HomeActivity.this, CunchuActivity.class);
startActivity(intent);
}
});
button02=(Button)findViewById(R.id.button2);
button02.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(HomeActivity.this, MusicActivity.class);
startActivity(intent);
}
});
}
}


Loading

0 comments on commit 4ec6488

Please sign in to comment.