forked from hzuapps/android-labs-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
Soft1614080902237/app/src/main/java/com/example/john/soft1614080902237/M3Activity.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,48 @@ | ||
package com.example.john.soft1614080902237; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.KeyEvent; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
public class M3Activity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_m3); | ||
final EditText editText=(EditText)findViewById(R.id.edit_text); | ||
//获取控件 | ||
Button btnLogin=(Button)findViewById(R.id.chaxun); | ||
Button buttonque=(Button)findViewById(R.id.queding); | ||
//final EditText EdPassword=(EditText) findViewById(R.id.edit_text); | ||
final EditText EdUserName=(EditText)findViewById(R.id.edit_text); | ||
|
||
btnLogin.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
SharedPreferences sharedPreferences = getSharedPreferences("jc", Context.MODE_PRIVATE);//创建SharedPreferences对象 | ||
SharedPreferences.Editor editor = sharedPreferences.edit(); //需要获取SharedPreferences的编辑对象 | ||
editor.putString("username", editText.getText().toString()); //向preferences写入数据: | ||
//editor.putString("Password", EdPassword.getText().toString()); | ||
editor.commit();// 向preferences文件中提交数据: | ||
Intent intent=new Intent(M3Activity.this,M5Activity.class); | ||
startActivity(intent); | ||
} | ||
} ); | ||
buttonque.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent=new Intent(M3Activity.this,M6Activity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Soft1614080902237/app/src/main/java/com/example/john/soft1614080902237/M5Activity.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,24 @@ | ||
package com.example.john.soft1614080902237; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.widget.TextView; | ||
|
||
public class M5Activity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_m5); | ||
TextView txtUserName=(TextView) findViewById(R.id.txt_UserName); | ||
// TextView txtPassword=(TextView) findViewById(R.id.txt_Password); | ||
|
||
SharedPreferences sharedPreferences = getSharedPreferences("jc", Context.MODE_PRIVATE); //创建SharedPreferences对象 | ||
String userName=sharedPreferences.getString("username","");//根据key获取对应的数据 | ||
//String password=sharedPreferences.getString("Password",""); | ||
// txtPassword.setText(password);//给TextView设置text的值 | ||
txtUserName.setText(userName); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Soft1614080902237/app/src/main/java/com/example/john/soft1614080902237/M6Activity.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,13 @@ | ||
package com.example.john.soft1614080902237; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
|
||
public class M6Activity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_m6); | ||
} | ||
} |
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,43 @@ | ||
<?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" | ||
tools:context=".M3Activity"> | ||
|
||
<LinearLayout | ||
android:id="@+id/linearLayout2" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:orientation="vertical" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
|
||
<EditText | ||
android:id="@+id/edit_text" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="10sp" | ||
android:hint="请输入搜索的书名..." | ||
android:maxLength="40" | ||
android:textColorHint="#238745" /> | ||
|
||
<Button | ||
android:id="@+id/queding" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="确定" /> | ||
|
||
<Button | ||
android:id="@+id/chaxun" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="end" | ||
android:text="查询记录" /> | ||
</LinearLayout> | ||
|
||
</android.support.constraint.ConstraintLayout> |
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,30 @@ | ||
<?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" | ||
tools:context=".M5Activity"> | ||
<RelativeLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content"> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="80sp" | ||
android:layout_marginLeft="30sp" | ||
android:text="搜索记录为:" | ||
android:textSize="40px"/> | ||
|
||
<TextView | ||
android:id="@+id/txt_UserName" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="80sp" | ||
android:layout_marginLeft="150sp" | ||
android:textSize="40px"/> | ||
|
||
</RelativeLayout> | ||
|
||
|
||
</android.support.constraint.ConstraintLayout> |
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,9 @@ | ||
<?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" | ||
tools:context=".M6Activity"> | ||
|
||
</android.support.constraint.ConstraintLayout> |