广告
返回顶部
首页 > 资讯 > 移动开发 >Android实现带头像的用户注册页面
  • 711
分享到

Android实现带头像的用户注册页面

Android 2022-06-06 08:06:28 711人浏览 泡泡鱼
摘要

1.首先是注册页面的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x

1.首先是注册页面的布局:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:Android="Http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="20px"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/linearLayout1"
android:orientation="vertical"
android:layout_weight="2"
android:paddingLeft="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:textSize="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名:" />
<EditText
android:id="@+id/user"
android:minWidth="400px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:textSize="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码:" />
<EditText
android:id="@+id/pwd"
android:inputType="textPassWord"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView3"
android:textSize="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确认密码:" />
<EditText
android:id="@+id/repwd"
android:inputType="textPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView4"
android:textSize="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-mail地址:" />
<EditText
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="158px"
android:layout_height="150px"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="选择头像" />
</LinearLayout>
</LinearLayout>

效果如下图所示:

2.然后是图库的页面布局,由用户去选择图片,这里我就用windows系统里面的几张照片:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<GridView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/gridView"
android:numColumns="4" />
</LinearLayout>

3.然后我们在注册页面的Activity写入以下代码:

点击按钮跳转到图库Activity页面中:


Button button1=(Button)findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,HeadActivity.class);
startActivityForResult(intent,0x11);
}
});

重写


@Override onActivityResult方法:
protected void onActivityResult(int requestCode,int resultCode,Intent data){
super.onActivityResult(requestCode,resultCode,data);
if(requestCode==0x11&&requestCode==0x11){
Bundle bundle=data.getExtras();
int imageId=bundle.getInt("imageId");
ImageView imageView=(ImageView)findViewById(R.id.imageView1);
imageView.setImageResource(imageId);
}
}

4.在图库Activity里面写入以下代码响应用户点击图片并通过Intent传递给前一个Activity:


GridView gridView=(GridView)findViewById(R.id.gridView);
BaseAdapter adapter=new BaseAdapter() {
@Override
public int getCount() {
return imageId.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if(convertView==null){
imageView=new ImageView(HeadActivity.this);
imageView.setAdjustViewBounds(true);
imageView.setMaxHeight(58);
imageView.setMaxWidth(50);
imageView.setPadding(5,5,5,5);
}else{
imageView=(ImageView)convertView;
}
imageView.setImageResource(imageId[position]);
return imageView;
}
};
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent=getIntent();
Bundle bundle=new Bundle();
bundle.putInt("imageId",imageId[position]);
intent.putExtras(bundle);
setResult(0x11,intent);
finish();
}
});

这里主要是重写getView方法:

5.然后我们点击运行界面如下:

6.我们点击按钮之后跳转Activity选择图片头像:

7.然后我们点击一个图片又跳转回去,头像更改:

您可能感兴趣的文章:Android实现本地上传图片并设置为圆形头像Android根据电话号码获得联系人头像实例代码Android使用CircleImageView实现圆形头像的方法Android实现从本地图库/相机拍照后裁剪图片并设置头像Android手机拍照或选取图库图片作为头像Android实现用户头像更换操作Android仿微信群聊头像Android获取联系人头像的方法Android自定义控件仿QQ编辑和选取圆形头像Android自定义AvatarImageView实现头像显示效果


--结束END--

本文标题: Android实现带头像的用户注册页面

本文链接: https://www.lsjlt.com/news/24908.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Android实现带头像的用户注册页面
    1.首先是注册页面的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x...
    99+
    2022-06-06
    Android
  • Android实现注册页面
    本文用Android studio制作了简单的手机QQ登录界面,其中界面的布局采用了线性布局、表格布局(不固定布局方法),并给控件绑定监听器,当用户点击登陆按钮时,把用户所填写的注册...
    99+
    2022-11-13
  • Android实现注册页面(携带数据包跳转)
    安卓学习:实现注册页面输入数据,点击注册按钮跳转到另一个页面并显示输入信息 效果: 实现 1.创建安卓文件 2.创建注册界面,勾选为启动页 3.编写代码 启动界面activi...
    99+
    2022-11-13
  • Android怎么实现注册页面
    本文小编为大家详细介绍“Android怎么实现注册页面”,内容详细,步骤清晰,细节处理妥当,希望这篇“Android怎么实现注册页面”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。实现的效果图:代码:package...
    99+
    2023-06-30
  • android实现注册页面开发
    本文实例为大家分享了android实现注册页面开发的具体代码,供大家参考,具体内容如下 在values文件里创建以下几个文件 colors代码: <xml version=...
    99+
    2022-11-13
  • Android实现登录注册页面(上)
    简单的Android开发登录注册,这个是没有连数据库的。 首先,新建项目,新建一个登录页面LoginActivity和注册页面RegisterActivity。 下面是登录页面的代码...
    99+
    2022-11-13
  • Android实现登录注册页面(下)
    前面我们已经完成了登录注册页面的布局,下面我们实现验证登录和记住密码的功能。 我们这里还没用到数据库,所以我们的验证的账号密码,是写死的。 首先进入登录页面,可以从这里跳转到注册页面...
    99+
    2022-11-13
  • node+vue实现用户注册和头像上传的实例代码
    最近正好空闲,写了个实用注册代码,分享给大家,有需要的朋友可以了解一下 数据库我使用的是MongoDB。 首先做文件上传,要保证协议里面的'Content-Type'为'multipa...
    99+
    2022-06-04
    用户注册 头像 实例
  • Android怎么实现注册页面并携带数据包跳转
    这篇文章主要讲解了“Android怎么实现注册页面并携带数据包跳转”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Android怎么实现注册页面并携带数据包跳转”吧!效果:实现1.创建安卓文件...
    99+
    2023-06-30
  • Android studio 实现app登录注册页面
    目录 activity_main.xml代码如下 MainActivity.java代码如下 用于高校实现Android studio专业课作业提交,如确实有用,欢迎观众姥爷打赏 该页面实现了注册页面的布局效果,包含用户名,密码,忘记密...
    99+
    2023-10-06
    android-studio adb android android studio
  • Android Studio怎么实现注册页面跳转登录页面
    今天小编给大家分享一下Android Studio怎么实现注册页面跳转登录页面的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了...
    99+
    2023-06-30
  • Android Studio实现带边框的圆形头像
    本文实例为大家分享了Android Studio实现带边框的圆形头像的具体代码,供大家参考,具体内容如下效果显示: (没有边框的)  (有边框的) 创建自定义ImagView控件 (1)、没有边框的package chenglon...
    99+
    2023-05-30
    android studio 圆形头像
  • Android实现用户头像更换操作
    你以为头像更换很容易?或许对于用户来讲,在微信上更换一个头像只是点击头像,选择拍照或相册,裁剪返回而已。但是对于程序员来说,要实现其实也挺吃力的(小火柴花了一个下午整理~_~)...
    99+
    2022-06-06
    Android
  • PHP利用ChatGPT实现轻松创建用户注册页面
    ChatGPT 是 OpenAI 开发的 GPT(Generative Pre-trained Transformer)语言模型的变体。它是一种大型单向语言模型,已在大型人类生成文本...
    99+
    2023-02-08
    PHP ChatGPT创建用户注册页面 PHP创建用户注册页面 PHP ChatGPT PHP注册页面
  • JS实现用户注册界面功能
    本文实例为大家分享了JS实现用户注册界面功能的具体代码,供大家参考,具体内容如下   1.css代码 *{ margin: 0; ...
    99+
    2022-11-12
  • Android开发----实现登录注册页面(创建本地数据库,对注册的账户密码进行存储)
    实现登录注册页面(创建本地数据库,对注册的账户密码进行存储) 写在前面: 本文实现了登录注册页面的开发,创建了本地数据库,存储注册的账户密码。注册账户为手机号,对账户为手机号进行了正则化验证。登录成功...
    99+
    2023-10-21
    数据库 android
  • Android实现用户圆形头像和模糊背景
    本文实例为大家分享了Android实现用户圆形头像和模糊背景的具体代码,供大家参考,具体内容如下 1、效果展示 2、在build.gradle(Module)中的dependenc...
    99+
    2022-11-12
  • AndroidStudio实现注册页面跳转登录页面的创建
    本文是用来介绍Android Studio创建注册页面跳转登录页面的界面设计以及跳转功能地实现,完整结构见文章结尾。 用户注册界面 <xml version="1.0" en...
    99+
    2022-11-13
  • JavaWeb之Servlet注册页面的实现示例
    Servlet-注册页面 环境准备: 本文所用到环境如下: 软件:Eclipse(2018) 服务器:Tomcat 9 在index.jsp添加相关的代码 <...
    99+
    2022-11-13
  • Android实现登录界面的注册功能
    本文实例为大家分享了Android登录界面的注册实现代码,供大家参考,具体内容如下 注册一个登录界面在控制台将输入的信息文本选框展示出来 xml界面设计(前面已发) <xml ...
    99+
    2022-11-13
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作