第一阶段冲刺
Posted wyppaa
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第一阶段冲刺相关的知识,希望对你有一定的参考价值。
第一阶段冲刺
觅踪1
昨天主要是对正则表达式的学习,今天家里的杂物比较多,忙活了一下午,晚上适当的做了一些按钮,为刚开始的登录注册页面做准备,睡了睡了
觅踪2
昨天的页面设计受到了停滞,今天换了一种形式,之前是直接用按键绘制,现在改为代码操纵,自己的进程缓慢了许多,明天将继续加油
界面代码如下:
复制代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:layout_gravity="center"
android:background="@drawable/tim">
<TextView
android:layout_width="match_parent"
android:layout_height="76dp"
android:layout_marginTop="25dp"
android:gravity="center"
android:text="@string/mizong"
android:textColor="#000000"
android:textSize="45sp"
android:textStyle="bold">
</TextView>
<RelativeLayout
android:id="@+id/text_1"
android:layout_height="70dp"
android:layout_width="match_parent"
android:layout_marginTop="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:text="@string/zhanghu"
android:textSize="35sp"
>
</TextView>>
<EditText
android:layout_height="50dp"
android:layout_width="match_parent"
android:autofillHints=""
android:layout_toRightOf="@id/text_1"
tools:ignore="NotSibling">
</EditText>
</RelativeLayout>>
<RelativeLayout
android:id="@+id/text_2"
android:layout_height="70dp"
android:layout_width="match_parent"
android:layout_marginTop="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:text="@string/password"
android:textSize="35sp"
>
</TextView>
<EditText
android:layout_height="50dp"
android:layout_width="match_parent"
android:autofillHints=""
android:inputType="textPassword"
android:layout_toRightOf="@id/text_2"
tools:ignore="NotSibling">
</EditText>
</RelativeLayout>>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp">
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="记住密码"
android:textSize="25sp"
android:layout_marginLeft="40dp">
</Switch>
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="忘记密码"
android:textSize="25sp"
android:layout_marginLeft="70dp"
>
</Switch>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="@string/denglu">
</Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="@string/zhuce"
>
</Button>
</LinearLayout>
</LinearLayout>
觅踪3
今天整体结束了登录界面的构造搭建,并且开始了下一阶段,也就是个人信息以及好友的功能开发整体来说,由于对于Android Studio的不熟练,开发进程略微嫌慢,后期慢慢的会加快进程
以下是本组登录界面的第一阶段目标的补充代码:
item1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView2"
android:layout_width="130dp"
android:layout_height="137dp"
android:contentDescription="TODO"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ima" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="84dp"
android:text="@string/name"
android:textColor="@android:color/black"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.126"
app:layout_constraintStart_toEndOf="@+id/imageView2" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/gexing"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.247"
app:layout_constraintStart_toEndOf="@+id/imageView2" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
activity-main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@drawable/tim"
tools:context=".MainActivity"
>
<RelativeLayout
android:id="@+id/rl_loginactivity_top"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@color/color_minefragment_top" >
<ImageView
android:id="@+id/iv_loginactivity_back"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/ic_left_back"
android:clickable="true"
android:onClick="onClick" />
<TextView
android:id="@+id/tv_loginactivity_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
android:textColor="#fff"
android:textSize="20dp"
android:layout_toRightOf="@+id/iv_loginactivity_back"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
/>
<TextView
android:id="@+id/tv_loginactivity_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注册"
android:textColor="#fff"
android:textSize="20dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:clickable="true"
android:onClick="onClick"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_loginactivity_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/rl_loginactivity_top"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_loginactivity_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名:"/>
<EditText
android:id="@+id/et_loginactivity_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="手机号/邮箱/用户名"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_loginactivity_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密 码:"/>
<EditText
android:id="@+id/et_loginactivity_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="登录密码"
android:inputType="textPassword"/>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/bt_loginactivity_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ll_loginactivity_two"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/selector_loginactivity_button"
android:text="登录"
android:textColor="#fff"
android:gravity="center"
android:onClick="onClick"
/>
</RelativeLayout>
activity_z_c.xml
<?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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".ui.login.ZCActivity">
<EditText
android:id="@+id/username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="96dp"
android:layout_marginEnd="24dp"
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:hint="@string/prompt_password"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/username" />
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginStart="48dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="48dp"
android:layout_marginBottom="64dp"
android:enabled="false"
android:text="@string/action_sign_in"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/password"
app:layout_constraintVertical_bias="0.2" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="32dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="64dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/password"
app:layout_constraintStart_toStartOf="@+id/password"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3" />
</androidx.constraintlayout.widget.ConstraintLayout>
觅踪4
今天继续完善登录、注册功能,看似简单,实则不易
Mainactivity
package com.example.demo2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private DBOpenHelper mDBOpenHelper;
private TextView mTvLoginactivityRegister;
private RelativeLayout mRlLoginactivityTop;
private EditText mEtLoginactivityUsername;
private EditText mEtLoginactivityPassword;
private LinearLayout mLlLoginactivityTwo;
private Button mBtLoginactivityLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
mDBOpenHelper = new DBOpenHelper(this);
}
private void initView() {
// 初始化控件
mBtLoginactivityLogin = findViewById(R.id.bt_loginactivity_login);
mTvLoginactivityRegister = findViewById(R.id.tv_loginactivity_register);
mRlLoginactivityTop = findViewById(R.id.rl_loginactivity_top);
mEtLoginactivityUsername = findViewById(R.id.et_loginactivity_username);
mEtLoginactivityPassword = findViewById(R.id.et_loginactivity_password);
mLlLoginactivityTwo = findViewById(R.id.ll_loginactivity_two);
// 设置点击事件监听器
mBtLoginactivityLogin.setOnClickListener(this);
mTvLoginactivityRegister.setOnClickListener(this);
}
public void onClick(View view) {
switch (view.getId()) {
// 跳转到注册界面
case R.id.tv_loginactivity_register:
startActivity(new Intent(this, item1Activity.class));
finish();
break;
case R.id.bt_loginactivity_login:
String name = mEtLoginactivityUsername.getText().toString().trim();
String password = mEtLoginactivityPassword.getText().toString().trim();
if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(password)) {
ArrayList<User> data = mDBOpenHelper.getAllData();
boolean match = false;
for (int i = 0; i < data.size(); i++) {
User user = data.get(i);
if (name.equals(user.getName()) && password.equals(user.getPassword())) {
match = true;
break;
} else {
match = false;
}
}
if (match) {
Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();//销毁此Activity
} else {
Toast.makeText(this, "用户名或密码不正确,请重新输入", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "请输入你的用户名或密码", Toast.LENGTH_SHORT).show();
}
break;
}
}
}
item1activity
package com.example.demo2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class item1Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView lv_list = (ListView) findViewById(R.id.lv_list);
lv_list.setAdapter(new MyAdapter());
}
private class MyAdapter extends BaseAdapter {
@Override
public int getCount() {
return 5;//返回值决定ListView展示多少条数据
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
if (convertView == null) {
view = View.inflate(item1Activity.this, R.layout.item1, null);
} else {
view = convertView;
}
return view;
}
}
}
觅踪5
冲刺阶段过半,开了一次小会,明确了第一阶段的冲刺目标,互相之间加油打气,队内相互鼓励,活跃了一下氛围
个人的登录功能的构建也日趋完善,期间也会有一些小问题,相互讨论,并在一些教程以及CSDN论坛的帖子中寻找解决问题的方法
Main2Activity
package com.example.demo2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
public class Main2Activity extends AppCompatActivity implements View.OnClickListener {
private String realCode;
private DBOpenHelper mDBOpenHelper;
private Button mBtRegisteractivityRegister;
private RelativeLayout mRlRegisteractivityTop;
private ImageView mIvRegisteractivityBack;
private LinearLayout mLlRegisteractivityBody;
private EditText mEtRegisteractivityUsername;
private EditText mEtRegisteractivityPassword1;
private EditText mEtRegisteractivityPassword2;
private EditText mEtRegisteractivityPhonecodes;
private ImageView mIvRegisteractivityShowcode;
private RelativeLayout mRlRegisteractivityBottom;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
initView();
mDBOpenHelper = new DBOpenHelper(this);
}
private void initView(){
mBtRegisteractivityRegister = findViewById(R.id.bt_registeractivity_register);
mRlRegisteractivityTop = findViewById(R.id.rl_registeractivity_top);
mIvRegisteractivityBack = findViewById(R.id.iv_registeractivity_back);
mLlRegisteractivityBody = findViewById(R.id.ll_registeractivity_body);
mEtRegisteractivityUsername = findViewById(R.id.et_registeractivity_username);
mEtRegisteractivityPassword1 = findViewById(R.id.et_registeractivity_password1);
mEtRegisteractivityPassword2 = findViewById(R.id.et_registeractivity_password2);
mIvRegisteractivityBack.setOnClickListener(this);
mBtRegisteractivityRegister.setOnClickListener(this);
}
public void onClick(View view) {
switch (view.getId()) {
case R.id.iv_registeractivity_back: //返回登录页面
Intent intent1 = new Intent(this, Main2Activity.class);
startActivity(intent1);
finish();
break;
case R.id.bt_registeractivity_register: //注册按钮
//获取用户输入的用户名、密码、验证码
String username = mEtRegisteractivityUsername.getText().toString().trim();
String password = mEtRegisteractivityPassword1.getText().toString().trim();
//注册验证
if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password) ) {
//将用户名和密码加入到数据库中
mDBOpenHelper.add(username, password);
Intent intent2 = new Intent(this, MainActivity.class);
startActivity(intent2);
finish();
Toast.makeText(this, "验证通过,注册成功", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(this, "未完善信息,注册失败", Toast.LENGTH_SHORT).show();
}
break;
}
}
}
User
package com.example.demo2;
public class User {
private String name; //用户名
private String password; //密码
public User(String name, String password) {
this.name = name;
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "User{" +
"name=‘" + name + ‘‘‘ +
", password=‘" + password + ‘‘‘ +
‘}‘;
}
}
DBOoenHelper
package com.example.demo2;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList;
public class DBOpenHelper extends SQLiteOpenHelper {
private SQLiteDatabase db;
public DBOpenHelper(Context context) {
super(context, "db_test", null, 1);
db = getReadableDatabase();
}
@Override
public void onCreate(SQLiteDatabase db){
db.execSQL("CREATE TABLE IF NOT EXISTS user(" +
"_id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name TEXT," +
"password TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
db.execSQL("DROP TABLE IF EXISTS user");
onCreate(db);
}
public void add(String name,String password){
db.execSQL("INSERT INTO user (name,password) VALUES(?,?)",new Object[]{name,password});
}
public void delete(String name,String password){
db.execSQL("DELETE FROM user WHERE name = AND password ="+name+password);
}
public void updata(String password){
db.execSQL("UPDATE user SET password = ?",new Object[]{password});
}
public ArrayList<User> getAllData(){
ArrayList<User> list = new ArrayList<User>();
Cursor cursor = db.query("user",null,null,null,null,null,"name DESC");
while(cursor.moveToNext()){
String name = cursor.getString(cursor.getColumnIndex("name"));
String password = cursor.getString(cursor.getColumnIndex("password"));
list.add(new User(name,password));
}
return list;
}
}
觅踪6
登录功能的完成,既是加油打气,也是开启新任务的连接。接下来,铆足气力攻克难关,研究地图可视化、定位功能以及路线的可视化
由于大家都没有接触过,也有向也一些学长请教,但还是无果
于是转向CSDN论坛,看了些前辈发布的关于调用Baidu、高德地图API的经验
觅踪7
经过昨天的学习、交流、讨论,对于地图的调用有了初步的了解认知,但是总体来说还是有些欠缺
开发的初期就遇到了一些问题,比如Baidu密钥的获取,SHA1指纹的获取
这里附上其中的一个较为详细的CSDN论坛的路径:
https://blog.csdn.net/Ivan_Keung/article/details/53819406
感觉还不错步骤还是挺详细的
觅踪8
距离冲刺结束还有两天,今天我们在CSDN论坛的帖子的步骤教学下,进行了临摹,先尝试着自己开发,但是经过了一天的奋斗之后,我们好像遇到了瓶颈,于是又召开了一次会议重新制定了目标,决定脚踏实地,明天先尝试着将帖子上的代码运行出来,再进行修改,学习把他转化成为我们自己的代码
觅踪9
按着昨天预想的步骤来走,其实不然,我们似乎遇到了大问题
在一步一步跟着帖子的指示下来,就在我们准备run的时候
他报错了,没错报错了,这是我们没有想到的
觅踪10
终于,在最后一天,初步实现了地图的可视化,虽然与我们预想的结果有些偏差,但总算是有了些进展
以上是关于第一阶段冲刺的主要内容,如果未能解决你的问题,请参考以下文章