将注册、登录界面完善完全,实现注册、登录、忘记密码、修改密码等功能,包括一些动画的实现美化并将代码进行了一些改进,例如一些回退跳转功能
This commit is contained in:
parent
0856c27e1d
commit
897a20f524
|
@ -50,4 +50,5 @@ dependencies {
|
|||
implementation ("com.squareup.okhttp3:logging-interceptor:4.9.3")
|
||||
implementation ("com.squareup.retrofit2:retrofit:2.9.0")
|
||||
implementation ("com.squareup.retrofit2:converter-gson:2.9.0")
|
||||
implementation("org.greenrobot:eventbus:3.3.1")
|
||||
}
|
|
@ -27,7 +27,19 @@
|
|||
android:name=".LoginMainActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".SpActivity"
|
||||
android:name=".Serch"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ViewAction"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Study"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Study_pinglunm"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ViewStart"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".welcome"
|
||||
|
|
|
@ -2,13 +2,79 @@ package com.example.liyueling_final;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ChangePasswordActivity extends AppCompatActivity {
|
||||
|
||||
EditText phone;
|
||||
EditText password;
|
||||
EditText repassword;
|
||||
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_change_password);
|
||||
|
||||
textView = findViewById(R.id.textView170);
|
||||
imageView = findViewById(R.id.imageView141);
|
||||
phone = findViewById(R.id.phone);
|
||||
password = findViewById(R.id.password1);
|
||||
repassword = findViewById(R.id.password2);
|
||||
textView = findViewById(R.id.textView170);
|
||||
imageView = findViewById(R.id.imageView141);
|
||||
|
||||
PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofFloat("translationY",-100,0);
|
||||
PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("alpha",0,1);
|
||||
PropertyValuesHolder propertyValuesHolder4 = PropertyValuesHolder.ofFloat("rotation",-15,0);
|
||||
ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageView,propertyValuesHolder,propertyValuesHolder4,propertyValuesHolder3);
|
||||
ValueAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(textView,propertyValuesHolder,propertyValuesHolder4,propertyValuesHolder3);
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
animator2.setDuration(1000);
|
||||
animator2.start();
|
||||
|
||||
findViewById(R.id.enter).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
String phoneNumber = phone.getText().toString();
|
||||
String userPassword = password.getText().toString();
|
||||
String reuserPassword = repassword.getText().toString();
|
||||
|
||||
if (phoneNumber.isEmpty() || userPassword.isEmpty() || reuserPassword.isEmpty()) {
|
||||
Toast.makeText(ChangePasswordActivity.this, "内容不能为空", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (!userPassword.equals(reuserPassword)) {
|
||||
Toast.makeText(ChangePasswordActivity.this, "两次输入密码不同", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
DBTools dbTools = new DBTools(ChangePasswordActivity.this,"test",null,1);//数据库的名字
|
||||
SQLiteDatabase sqLiteDatabase = dbTools.getWritableDatabase();
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("password",userPassword);
|
||||
sqLiteDatabase.update("user", contentValues,
|
||||
"phone=?", new String[]{phoneNumber});
|
||||
|
||||
Intent intent = new Intent(ChangePasswordActivity.this, LoginMainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.example.liyueling_final;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class DBTools extends SQLiteOpenHelper {
|
||||
|
||||
public DBTools(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
|
||||
super(context, name, factory, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
//创建数据库和表
|
||||
db.execSQL("create table user(id integer primary key autoincrement,phone varchar(20),password varchar(20) )");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
//更新数据库表的信息
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -2,12 +2,19 @@ package com.example.liyueling_final;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import retrofit2.Call;
|
||||
|
@ -20,11 +27,31 @@ public class EnrollActivity extends AppCompatActivity {
|
|||
EditText phone;
|
||||
EditText password;
|
||||
EditText repassword;
|
||||
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_enroll);
|
||||
|
||||
textView = findViewById(R.id.textView170);
|
||||
imageView = findViewById(R.id.imageView141);
|
||||
phone = findViewById(R.id.phone);
|
||||
password = findViewById(R.id.password1);
|
||||
repassword = findViewById(R.id.password2);
|
||||
|
||||
PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofFloat("translationY", -100, 0);
|
||||
PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("alpha", 0, 1);
|
||||
PropertyValuesHolder propertyValuesHolder4 = PropertyValuesHolder.ofFloat("rotation", -15, 0);
|
||||
ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageView, propertyValuesHolder, propertyValuesHolder4, propertyValuesHolder3);
|
||||
ValueAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(textView, propertyValuesHolder, propertyValuesHolder4, propertyValuesHolder3);
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
animator2.setDuration(1000);
|
||||
animator2.start();
|
||||
|
||||
findViewById(R.id.enter).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
|
||||
|
@ -43,40 +70,24 @@ public class EnrollActivity extends AppCompatActivity {
|
|||
Toast.makeText(EnrollActivity.this, "两次输入密码不同", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
userApi api2 = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(userApi.class);
|
||||
try {
|
||||
Call<User> call = api2.Enroll(phoneNumber,userPassword);
|
||||
call.enqueue(new Callback<User>() {
|
||||
@Override
|
||||
public void onResponse(Call<User> call, Response<User> response) {
|
||||
User user = response.body();
|
||||
if (user != null && user.password.equals(userPassword)) {
|
||||
Intent intent = new Intent(EnrollActivity.this, LoginMainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
// 注册失败
|
||||
Toast.makeText(EnrollActivity.this, "注册失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Call<User> call, Throwable t) {
|
||||
Toast.makeText(EnrollActivity.this, "Network error", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("YourTag", "Error occurred: " + e.getMessage()); // 打印异常信息
|
||||
}
|
||||
DBTools dbTools = new DBTools(EnrollActivity.this,"test",null,1);//数据库的名字
|
||||
SQLiteDatabase sqLiteDatabase = dbTools.getWritableDatabase();
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("phone",phoneNumber);
|
||||
contentValues.put("password",userPassword);
|
||||
sqLiteDatabase.insert("user",null,contentValues);
|
||||
|
||||
Intent intent = new Intent(EnrollActivity.this, LoginMainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
findViewById(R.id.textView174).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(EnrollActivity.this,LoginMainActivity.class);
|
||||
Intent intent = new Intent(EnrollActivity.this, LoginMainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -2,21 +2,41 @@ package com.example.liyueling_final;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ForgetPasswordActivity extends AppCompatActivity {
|
||||
|
||||
EditText yanzhen;
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_forget_password);
|
||||
yanzhen = findViewById(R.id.password1);
|
||||
|
||||
textView = findViewById(R.id.textView170);
|
||||
imageView = findViewById(R.id.imageView141);
|
||||
|
||||
PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofFloat("translationY",-100,0);
|
||||
PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("alpha",0,1);
|
||||
PropertyValuesHolder propertyValuesHolder4 = PropertyValuesHolder.ofFloat("rotation",-15,0);
|
||||
ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageView,propertyValuesHolder,propertyValuesHolder4,propertyValuesHolder3);
|
||||
ValueAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(textView,propertyValuesHolder,propertyValuesHolder4,propertyValuesHolder3);
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
animator2.setDuration(1000);
|
||||
animator2.start();
|
||||
|
||||
findViewById(R.id.fasong).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package com.example.liyueling_final;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -24,6 +31,11 @@ public class LoginMainActivity extends AppCompatActivity {
|
|||
private RadioButton radioButton;
|
||||
EditText phone;
|
||||
EditText password;
|
||||
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
boolean flag;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -32,12 +44,30 @@ public class LoginMainActivity extends AppCompatActivity {
|
|||
phone = findViewById(R.id.phone);
|
||||
password = findViewById(R.id.password1);
|
||||
|
||||
textView = findViewById(R.id.textView170);
|
||||
imageView = findViewById(R.id.imageView141);
|
||||
|
||||
PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofFloat("translationY", -100, 0);
|
||||
PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("alpha", 0, 1);
|
||||
PropertyValuesHolder propertyValuesHolder4 = PropertyValuesHolder.ofFloat("rotation", -15, 0);
|
||||
ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageView, propertyValuesHolder, propertyValuesHolder4, propertyValuesHolder3);
|
||||
ValueAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(textView, propertyValuesHolder, propertyValuesHolder4, propertyValuesHolder3);
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
animator2.setDuration(1000);
|
||||
animator2.start();
|
||||
|
||||
DBTools dbTools = new DBTools(LoginMainActivity.this, "test", null, 1);//数据库的名字
|
||||
SQLiteDatabase sqLiteDatabase = dbTools.getWritableDatabase();
|
||||
|
||||
|
||||
findViewById(R.id.enter).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
|
||||
@SuppressLint("Range")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
flag = true;
|
||||
|
||||
String phoneNumber = phone.getText().toString();
|
||||
String userPassword = password.getText().toString();
|
||||
|
@ -50,40 +80,29 @@ public class LoginMainActivity extends AppCompatActivity {
|
|||
Toast.makeText(LoginMainActivity.this, "请同意协议", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
userApi api2 = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(userApi.class);
|
||||
try {
|
||||
Call<User> call = api2.Login(phoneNumber);
|
||||
call.enqueue(new Callback<User>() {
|
||||
@Override
|
||||
public void onResponse(Call<User> call, Response<User> response) {
|
||||
User user = response.body();
|
||||
if (user != null && user.password.equals(userPassword)) {
|
||||
Intent intent = new Intent(LoginMainActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
} else {
|
||||
// 登录失败
|
||||
Toast.makeText(LoginMainActivity.this, "Login failed", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Call<User> call, Throwable t) {
|
||||
Toast.makeText(LoginMainActivity.this, "Network error", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("YourTag", "Error occurred: " + e.getMessage()); // 打印异常信息
|
||||
Cursor cursor = sqLiteDatabase.query("user", new String[]{"id", "phone", "password"},
|
||||
"phone=?", new String[]{phoneNumber}, null, null, null);
|
||||
while (cursor.moveToNext()) {
|
||||
if (cursor != null && cursor.getString(cursor.getColumnIndex("password")).equals(userPassword)) {
|
||||
Intent intent = new Intent(LoginMainActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
if(flag==true){
|
||||
Toast.makeText(LoginMainActivity.this, "手机号或密码不正确", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
findViewById(R.id.textView174).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginMainActivity.this,EnrollActivity.class);
|
||||
Intent intent = new Intent(LoginMainActivity.this, EnrollActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
@ -91,7 +110,7 @@ public class LoginMainActivity extends AppCompatActivity {
|
|||
findViewById(R.id.textView175).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginMainActivity.this,ForgetPasswordActivity.class);
|
||||
Intent intent = new Intent(LoginMainActivity.this, ForgetPasswordActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
package com.example.liyueling_final;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class Serch extends AppCompatActivity {
|
||||
|
||||
TextView cancel;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_serch);
|
||||
|
||||
findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.example.liyueling_final;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class SpActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sp);
|
||||
|
||||
findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("user",MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString("name","计科一班");
|
||||
editor.putBoolean("isLogin",true);
|
||||
editor.commit();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("user",MODE_PRIVATE);
|
||||
String name = sharedPreferences.getString("name","");
|
||||
boolean isLogin = sharedPreferences.getBoolean("isLogin",false);
|
||||
Log.i("test",name+isLogin);
|
||||
}
|
||||
});
|
||||
findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("user",MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -7,53 +7,8 @@ import android.view.ViewGroup;
|
|||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Use the {@link Study_mulu#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class Study_mulu extends Fragment {
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
public Study_mulu() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment Study_mulu.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static Study_mulu newInstance(String param1, String param2) {
|
||||
Study_mulu fragment = new Study_mulu();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.example.liyueling_final;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
@ -14,11 +17,10 @@ import android.widget.TextView;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class welcome extends AppCompatActivity {
|
||||
|
||||
private TranslateAnimation ra;
|
||||
private TranslateAnimation rb;
|
||||
TextView textView;
|
||||
ImageView imageView;
|
||||
ImageView imageView2;
|
||||
ImageView imageView3;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -26,27 +28,32 @@ public class welcome extends AppCompatActivity {
|
|||
|
||||
textView = findViewById(R.id.textView169);
|
||||
imageView = findViewById(R.id.imageView);
|
||||
rb = new TranslateAnimation(Animation.RELATIVE_TO_SELF,0,Animation.RELATIVE_TO_SELF,0,
|
||||
Animation.RELATIVE_TO_SELF,0,Animation.RELATIVE_TO_SELF,0.5f);
|
||||
imageView2 = findViewById(R.id.enter);
|
||||
imageView3 = findViewById(R.id.imageView143);
|
||||
|
||||
PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofFloat("translationY",-100,0);
|
||||
PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("alpha",0,1);
|
||||
PropertyValuesHolder propertyValuesHolder4 = PropertyValuesHolder.ofFloat("rotation",-15,0);
|
||||
ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageView,propertyValuesHolder,propertyValuesHolder4,propertyValuesHolder3);
|
||||
ValueAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(textView,propertyValuesHolder,propertyValuesHolder4,propertyValuesHolder3);
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
animator2.setDuration(1000);
|
||||
animator2.start();
|
||||
|
||||
|
||||
ra = new TranslateAnimation(Animation.RELATIVE_TO_SELF,-0.5f,Animation.RELATIVE_TO_SELF,0.5f,
|
||||
Animation.RELATIVE_TO_SELF,0,Animation.RELATIVE_TO_SELF,0);
|
||||
ra.setDuration(1000);
|
||||
ra.setRepeatMode(Animation.REVERSE);
|
||||
ra.setInterpolator(new AccelerateInterpolator());
|
||||
ra.setFillAfter(true);
|
||||
|
||||
rb.setDuration(1000);
|
||||
rb.setRepeatMode(Animation.REVERSE);
|
||||
rb.setInterpolator(new AccelerateInterpolator());
|
||||
rb.setFillAfter(true);
|
||||
textView.startAnimation(rb);
|
||||
imageView.startAnimation(rb);
|
||||
ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(imageView,"translationY",-200,0);
|
||||
objectAnimator2.setDuration(1000);
|
||||
objectAnimator2.start();
|
||||
findViewById(R.id.enter).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
v.startAnimation(ra);
|
||||
PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofFloat("translationX",-50,50);
|
||||
PropertyValuesHolder propertyValuesHolder3 = PropertyValuesHolder.ofFloat("alpha",1,0.2f);
|
||||
ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(imageView2,propertyValuesHolder,propertyValuesHolder3);
|
||||
animator.setDuration(1000);
|
||||
animator.start();
|
||||
|
||||
|
||||
Intent intent = new Intent(welcome.this, LoginMainActivity.class);
|
||||
startActivity(intent);
|
||||
|
|
|
@ -115,17 +115,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/password1" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radioButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="登录即同意用户协议"
|
||||
android:textColor="#515151"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView174"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
app:layout_constraintVertical_bias="0.697" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView145"
|
||||
android:id="@+id/cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="取消"
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?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=".SpActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="44dp"
|
||||
android:text="增加数据"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="查询数据"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="删除数据"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button2" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue