diff --git a/Soft1613071002205/app5/src/main/AndroidManifest.xml b/Soft1613071002205/app5/src/main/AndroidManifest.xml new file mode 100644 index 000000000..f9eb752a1 --- /dev/null +++ b/Soft1613071002205/app5/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/Main2Activity.java b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/Main2Activity.java new file mode 100644 index 000000000..56bc7cc90 --- /dev/null +++ b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/Main2Activity.java @@ -0,0 +1,25 @@ +package com.example.jeremy.soft1613071002205; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.widget.TextView; + +public class Main2Activity extends AppCompatActivity { + private TextView mTextViewGetUserName; + private TextView mTextViewGetPassword; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.mynews); + mTextViewGetUserName = (TextView) findViewById(R.id.textView2); + mTextViewGetPassword = (TextView) findViewById(R.id.textView3); + Bundle b = getIntent().getBundleExtra("data"); + String getStringUserName = b.getString("username"); + mTextViewGetUserName.setText(getStringUserName); + String getStringPassword = b.getString("password"); + mTextViewGetPassword.setText(getStringPassword); + + + } +} diff --git a/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/MainActivity.java b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/MainActivity.java new file mode 100644 index 000000000..213b014f7 --- /dev/null +++ b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/MainActivity.java @@ -0,0 +1,57 @@ +package com.example.jeremy.soft1613071002205; + + +import android.app.Activity; +import android.content.Intent; +import android.content.SharedPreferences; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; + +public class MainActivity extends AppCompatActivity { + + private Button 登录; + private EditText 用户名; + private EditText 密码; + private SharedPreferences mSharePreferences; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + mSharePreferences = getSharedPreferences("data", MODE_PRIVATE); + + 用户名 = (EditText) findViewById(R.id.editText); + 密码 = (EditText) findViewById(R.id.editText2); + //取出数据并渲染 + + 登录 = (Button) findViewById(R.id.login); + 登录.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String stringUsername = 用户名.getText().toString(); + String stringPassword = 密码.getText().toString(); + // 2. 调用SharedPreferences.edit()方法,返回SharedPreferences.Editor对象,用于写入数据; + SharedPreferences.Editor editor = mSharePreferences.edit(); + //3. 调用SharedPreferences.Editor.putXxx(String key, xxx Value)方法以键值对的形式保存数据; + editor.putString("user", stringUsername); + editor.putString("password", stringPassword); + // 4. 调用SharedPreferences.Editor.commit()方法提交数据。 + editor.commit(); + + Intent intent = new Intent(MainActivity.this, User.class); + Bundle bundle = new Bundle(); + bundle.putString("username", stringUsername); + bundle.putString("password", stringPassword); + intent.putExtra("data", bundle); + + startActivity(intent); + } + + }); + } +} diff --git a/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/User.java b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/User.java new file mode 100644 index 000000000..addcb04e1 --- /dev/null +++ b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/User.java @@ -0,0 +1,28 @@ +package com.example.jeremy.soft1613071002205; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; + +import java.util.Map; + +public class User extends AppCompatActivity { + + private Button mReturnButton; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.mynews); + mReturnButton = (Button)findViewById(R.id.returnback); + } + public void back_to_login(View view) { + Intent intent3 = new Intent(User.this,MainActivity.class) ; + startActivity(intent3); + finish(); + } + + +} \ No newline at end of file diff --git "a/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/\344\270\273\347\225\214\351\235\242.java" "b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/\344\270\273\347\225\214\351\235\242.java" new file mode 100644 index 000000000..eb3e33721 --- /dev/null +++ "b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/\344\270\273\347\225\214\351\235\242.java" @@ -0,0 +1,13 @@ +package com.example.jeremy.soft1613071002205; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +public class 主界面 extends AppCompatActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.home); + } + +} \ No newline at end of file diff --git "a/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/\344\277\241\346\201\257\345\217\221\345\270\203.java" "b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/\344\277\241\346\201\257\345\217\221\345\270\203.java" new file mode 100644 index 000000000..7cc2f7e68 --- /dev/null +++ "b/Soft1613071002205/app5/src/main/java/com/example/jeremy/soft1613071002205/\344\277\241\346\201\257\345\217\221\345\270\203.java" @@ -0,0 +1,32 @@ +package com.example.jeremy.soft1613071002205; + + +import android.app.Activity; +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; + +public class 信息发布 extends AppCompatActivity { + + private Button 信息发布; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.home); + + + 信息发布 = (Button) findViewById(R.id.button); + 信息发布.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(信息发布.this,主界面.class); + startActivity(intent); + } + + }); + } + } \ No newline at end of file diff --git a/Soft1613071002205/app5/src/main/res/layout/activity_main.xml b/Soft1613071002205/app5/src/main/res/layout/activity_main.xml new file mode 100644 index 000000000..343af53f0 --- /dev/null +++ b/Soft1613071002205/app5/src/main/res/layout/activity_main.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + +