Android使用mysql实现修改用户信息(暂不包括头像修改) 简易新闻(十一)
关于
本篇属于简易新闻第十一篇,所以内容上具有连贯性,但是核心的用户修改以及布局点击事件是和之前没有关系的,依然可做参考。
本篇使用了第三方MateriaDialog
添加引用如下:
//第三方弹出框
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
效果图
第一步,修改activity_user_data.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
//在color.xml文件夹下添加的颜色 颜色代码 #eeeeee
android:background="@color/colorbackground"
tools:context=".UserMode.User_DataActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/userData_toolbar"
android:layout_width="match_parent"
android:layout_height="40dp"
//白色代码#fff
app:titleTextColor="@color/white"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
//背景色 #3A91FB
android:background="@color/title"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<LinearLayout
android:id="@+id/lay_touxiang"
android:orientation="horizontal"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="300dp"
android:layout_height="match_parent"
android:background="#01000000"
android:gravity="center_vertical"
android:text="头像"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView_user"
android:layout_width="55dp"
android:background="#01000000"
android:layout_height="55dp"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/black"
/>
<LinearLayout
android:id="@+id/layout_name"
android:orientation="horizontal"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="55dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:background="#01000000"
android:gravity="center_vertical"
android:text="用户名"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_nc_fb"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#01000000"
android:gravity="center_vertical|center|right" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="20dp"
//这个图片来源你可以自己百度上copy一个下来
android:src="@drawable/pdf_next"
tools:ignore="RtlHardcoded" />
</LinearLayout>
//View作为中间间隔线
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/black"
/>
<LinearLayout
android:id="@+id/layout_sex"
android:orientation="horizontal"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_weight="1"
android:background="#01000000"
android:gravity="center_vertical"
android:text="性别"
android:textStyle="bold" />
<TextView
android:id="@+id/text_Sex"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#01000000"
android:gravity="center_vertical|center|right"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="20dp"
android:src="@drawable/pdf_next"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/black"
/>
<LinearLayout
android:id="@+id/layout_Age"
android:orientation=</