master
hayden 2 years ago
parent 2850f49a7c
commit 74810e5586

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -36,5 +36,7 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'liji.library.dev:citypickerview:1.1.0'
}

@ -6,18 +6,21 @@
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/app_icon"
android:roundIcon="@drawable/app_icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication"
android:theme="@style/AppTheme"
tools:targetApi="31">
<activity
android:name=".LoginActivity"
android:exported="true">
<intent-filter>
<!-- app启动时的入口-->
<action android:name="android.intent.action.MAIN" />
<!-- 在桌面上显示qpp图标-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@ -25,21 +28,13 @@
<activity
android:name=".RigsterActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MineActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

@ -1,12 +1,31 @@
package com.example.myapplication;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
public class LoginActivity extends AppCompatActivity implements View.OnClickListener{
public class LoginActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_login);
findViewById(R.id.login).setOnClickListener(this);
findViewById(R.id.rigster).setOnClickListener(this);
}
@Override
public void onClick(View view) {
if(view.getId() == R.id.rigster){
startActivity(new Intent(this,RigsterActivity.class));
}else{
startActivity(new Intent(this,MineActivity.class));
}
}
}

@ -2,16 +2,25 @@ package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MineActivity extends AppCompatActivity {
public class MineActivity extends AppCompatActivity implements View.OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mine);
findViewById(R.id.outload).setOnClickListener(this);
}
}
@Override
public void onClick(View view) {
if(view.getId() == R.id.outload){
//待修改,因為這樣數據還在
finish();
}
}
}

@ -2,45 +2,145 @@ package com.example.myapplication;
import android.app.Activity;
import android.app.AppComponentFactory;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class RigsterActivity extends Activity {
import com.lljjcoder.citypickerview.widget.CityPicker;
public class RigsterActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
private EditText usernameEdit,passEdit,surePasswordEdit;
private TextView cityText;
private CityPicker cityPicker;
private Button regButton;
private RadioGroup sexGroup;
private String sexStr = "男";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_rigster);
init();
}
private void init(){
cityText = findViewById(R.id.ri_province);
cityText.setOnClickListener(this);
usernameEdit = findViewById(R.id.rig_username);
passEdit = findViewById(R.id.rig_password);
surePasswordEdit = findViewById(R.id.re_password);
regButton = findViewById(R.id.re_register);
regButton.setOnClickListener(this);
sexGroup = findViewById(R.id.sex);
sexGroup.setOnCheckedChangeListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.ri_province:
initCityPicker();
cityPicker.show();
break;
case R.id.re_register:
//注册验证方法
validateRegister();
break;
}
}
}
// //界面组件初始化
// private void init(){
// cityText = findViewById(R.id.ri_province);
// cityText.setOnClickListener(this);
// }
//
// @Override
// public void onClick(View v) {
// switch(v.getId()){
// case R.id.ri_province:
// initCityPicker();
// cityPicker.show();
// break;
// }
// }
//
// //初始化城市选择器
// private void initCityPicker() {
// cityPicker = new CityPicker.Builder(RigsterActivity.this)
// .textSize(16)
// .title("地址选择")
// .backgroundPop(0xa0000000)
// .title
// }
//}
//初始化城市选择爱
//初始化城市选择器
private void initCityPicker() {
cityPicker = new CityPicker.Builder(RigsterActivity.this)
.textSize(16)
.title("地址选择")
.backgroundPop(0xa0000000)
.titleBackgroundColor("#EfB81c")
.titleTextColor("#000000")
.backgroundPop(0xa0000000)
.confirTextColor("#000000")
.cancelTextColor("#000000")
.province("湖南省")
.city("长沙市")
.district("雨花区")
.textColor(Color.parseColor("#000000"))
.provinceCyclic(true)
.cityCyclic(false)
.districtCyclic(false)
.visibleItemsCount(7)
.itemPadding(10)
.onlyShowProvinceAndCity(false).build();
cityPicker.setOnCityItemClickListener(new CityPicker.OnCityItemClickListener(){
@Override
public void onSelected(String...strings){
String province = strings[0];
String city = strings[1];
String district = strings[2];
cityText.setText(String.format("%s %s %s",province,city,district));
}
@Override
public void onCancel() {
}
});
}
//注册验证
public void validateRegister(){
Intent intent = new Intent(RigsterActivity.this,LoginActivity.class);
String username = usernameEdit.getText().toString();
String password = passEdit.getText().toString();
String surePassword = surePasswordEdit.getText().toString();
String city = cityText.getText().toString();
//判断两次密码是否一致
if(password.equals(surePassword)){
if(!username.equals("") || !password.equals("")) {
if (!city.equals("")) {
Bundle bundle = new Bundle();
bundle.putString("username", username);
bundle.putString("password", password);
bundle.putString("sex", sexStr);
bundle.putString("city", city);
intent.putExtras(bundle);
startActivity(intent);
} else {
Toast.makeText(RigsterActivity.this, "请选择地址",
Toast.LENGTH_SHORT).show();
}
}else {
Toast.makeText(RigsterActivity.this,"账号或密码未填写",
Toast.LENGTH_SHORT).show();
}
}else {
Toast.makeText(RigsterActivity.this,"两次密码输入不一致",
Toast.LENGTH_SHORT).show();
}
Toast.makeText(RigsterActivity.this,"注册成功",Toast.LENGTH_SHORT).show();
}
@Override
public void onCheckedChanged(RadioGroup group,int checkedId){
// 根据用户的选择来改变性别
sexStr = checkedId == R.id.rig_man?"男":"女";
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

@ -5,11 +5,11 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white">
<!--APP Login 以及名字-->
<!--APP Login 以及名字-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="150dp"
android:layout_height="140dp"
android:layout_marginTop="100dp"
android:gravity="center_horizontal"
android:orientation="vertical">
@ -95,7 +95,7 @@
android:textSize="18sp" />
<Button
android:id = "@+id/register"
android:id = "@+id/rigster"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_marginTop="20dp"
@ -107,8 +107,4 @@
</LinearLayout>
</LinearLayout>

@ -104,6 +104,7 @@
android:layout_gravity="center_vertical"
android:src="@drawable/sex" />
<RadioGroup
android:id="@+id/sex"
android:layout_width="230dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
@ -146,7 +147,7 @@
android:maxLength="10"
android:maxLines="1"
android:hint="地址选择"
android:textSize="15px"/>
android:textSize="15dp"/>
</LinearLayout>
<LinearLayout

@ -18,4 +18,5 @@ android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
android.enableJetifier=true

@ -1,5 +1,9 @@
pluginManagement {
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
jcenter()
google()
mavenCentral()
gradlePluginPortal()
@ -8,9 +12,18 @@ pluginManagement {
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
jcenter()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "My Application"
include ':app'

Loading…
Cancel
Save