Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

#5 #53 实验4.5代码以及报告 #1641

Merged
merged 18 commits into from
Jan 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions students/net1814080903310/Information1814080903310Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,74 @@

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import edu.hzuapps.androidlabs.R;

public class Information1814080903310Activity extends AppCompatActivity {
private EditText PersonName;
private EditText EmailAddress;
private EditText Phone;
private Button write;
private Button read;
private Context This;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main1814080903310);
setContentView(R.layout.activity_info1814080903310);

PersonName = (EditText)findViewById(R.id.editTextTextPersonName);
EmailAddress = (EditText)findViewById(R.id.editTextTextEmailAddress);
Phone = (EditText)findViewById(R.id.editTextPhone);
read = (Button)findViewById(R.id.read);
write = (Button)findViewById(R.id.write);
}

public void onClick(View view){
String mPersonName = PersonName.getText().toString();
String mEmailAddress = EmailAddress.getText().toString();
String mPhone = Phone.getText().toString();

switch (view.getId()){
case R.id.write:
msave(mPersonName,mEmailAddress,mPhone);
break;
case R.id.read:
mread();
break;
}
}

private void mread(){
SharedPreferences sp = getSharedPreferences("info",MODE_PRIVATE);
String mPersonName = sp.getString("1","");
String mEmailAddress = sp.getString("2","");
String mPhone = sp.getString("3","");
PersonName.setText("");
EmailAddress.setText("");
Phone.setText("");
Toast.makeText(this,"昵称为:"+mPersonName+"邮箱为:"+mEmailAddress+"电话为:"+mPhone,Toast.LENGTH_LONG).show();
}
}
private boolean msave(String PersonName,String EmailAddress,String Phone){
SharedPreferences sp = getSharedPreferences("info",MODE_PRIVATE);
SharedPreferences.Editor edit = sp.edit();
edit.putString("1",PersonName);
edit.putString("2",EmailAddress);
edit.putString("3",Phone);
edit.apply();
Toast.makeText(this,"保存成功",Toast.LENGTH_SHORT).show();
return true;
}

}
28 changes: 21 additions & 7 deletions students/net1814080903310/Net1814080903310Activity.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
package edu.hzuapps.androidlabs.students.net1814080903310;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import edu.hzuapps.androidlabs.R;

public class Net1814080903310Activity extends AppCompatActivity {

Button button = null;
Button button1 =null;
@Override
protected void onCreat(Bundle savedInstanceState){
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = findViewById(R.id.see);
final Net1814080903310Activity _this = this;

button = (Button)findViewById(R.id.video);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(_this, Main1814080903310Activity.class);
_this.startActivity(intent);
Intent intent =new Intent();
intent.setClass(Net1814080903310Activity.this,PlayVideo18148080903310Activity.class);
startActivity(intent);
}
});

button1 = (Button)findViewById(R.id.info);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(Net1814080903310Activity.this,Information1814080903310Activity.class);
startActivity(intent);
}
});
}
Expand Down
49 changes: 47 additions & 2 deletions students/net1814080903310/PlayVideo18148080903310Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,58 @@

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

import edu.hzuapps.androidlabs.R;

public class PlayVideo18148080903310Activity extends AppCompatActivity {
private VideoView videoView;
private Button startVideo;
private Button stopVideo;
private MediaController mediaController;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first18148080903310);
setContentView(R.layout.activity_play18148080903310);
intView();
}

private void intView(){
videoView = (VideoView)findViewById(R.id.videoView2);
startVideo = (Button)findViewById(R.id.startVideo);
stopVideo = (Button)findViewById(R.id.stopVideo);

startVideo.setOnClickListener(new View.OnClickListener(){

@Override
public void onClick(View v) {
init();
}
});
stopVideo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
videoView.stopPlayback();
}
});
}

private void init(){
videoView = (VideoView)findViewById(R.id.videoView2);
mediaController = new MediaController(this);
String uri = "android.resource://"+getPackageName()+"/"+R.raw.video;
videoView.setVideoURI(Uri.parse(uri));
videoView.setMediaController(mediaController);
mediaController.setMediaPlayer(videoView);
videoView.requestFocus();
videoView.start();
}
}
}

80 changes: 80 additions & 0 deletions students/net1814080903310/activity_info1814080903310.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".students.net1814080903310.Information1814080903310Activity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入您的昵称" />

<EditText
android:id="@+id/editTextTextPersonName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name" />

<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入您的邮箱" />

<EditText
android:id="@+id/editTextTextEmailAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textEmailAddress" />

<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入您的电话" />

<EditText
android:id="@+id/editTextPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<Button
android:id="@+id/write"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClick"
android:text="保存" />

<Button
android:id="@+id/read"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClick"
android:text="读取"
tools:ignore="OnClick" />
</LinearLayout>

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

53 changes: 31 additions & 22 deletions students/net1814080903310/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,47 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<TextView
android:id="@+id/textview_01"
<Button
android:id="@+id/video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/InfomationBackground"
android:text="Hello World!"
android:layout_marginStart="43dp"
android:layout_marginTop="13dp"
android:layout_marginEnd="100dp"
android:layout_marginBottom="43dp"
android:text="视频"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/info"
app:layout_constraintTop_toBottomOf="@+id/imageView" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="首页"
tools:ignore="MissingConstraints" />
<ImageView
android:id="@+id/imageView"
android:layout_width="410dp"
android:layout_height="627dp"
android:layout_marginBottom="8dp"
android:src="@drawable/infomationbackground"
app:layout_constraintBottom_toTopOf="@+id/video"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/button2"
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="92dp"
android:layout_marginTop="13dp"
android:layout_marginEnd="43dp"
android:layout_marginBottom="38dp"
android:text="我的"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="59dp"
tools:ignore="MissingConstraints" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/video"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/InfomationBackground"
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
47 changes: 47 additions & 0 deletions students/net1814080903310/activity_play1814080903310.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
tools:context=".students.net1814080903310.PlayVideo18148080903310Activity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<VideoView
android:id="@+id/videoView2"
android:layout_width="354dp"
android:layout_height="242dp"
android:layout_weight="1" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/startVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="播放" />

<Button
android:id="@+id/stopVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="结束" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Loading