Android带头像的用户注册页面
详细的图文可以到我的百度经验去查看:http://jingyan.baidu.com/article/cd4c2979eda109756e6e60de.html
首先是注册页面的布局:
<?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>
然后是图库的页面布局,由用户去选择图片,这里我就用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="" />
</LinearLayout>
然后我们在注册页面的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);
}
}
点击按钮跳转到图库Activity页面中。
在图库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();
}
});
结果如下:

Android带头像的用户注册页面的更多相关文章
- 超详细的php用户注册页面填写信息完整实例(附源码)
这篇文章主要介绍了一个超详细的php用户注册页面填写信息完整实例,内容包括邮箱自动匹配.密码强度验证以及防止表单重复等,小编特别喜欢这篇文章,推荐给大家. 注册页面是大多数网站必备的页面,所以很有必要 ...
- 实现android手机来电拦截系统页面弹出自定义页面特效
如何实现android手机来电拦截系统页面弹出自定义页面特效, 首先: 我们需要注册一个监听来电的广播PhoneStateReceiver 类:其次: 在onReceive里面我们获取an ...
- JavaScript、CSS、JSP 实现用户注册页面与信息校验
参考:http://blog.csdn.net/fightfaith/article/details/50277337 需求:实现用户注册页面并作出逻辑校验.要求: (1)完成注册页面样式如下: (2 ...
- Android 获取浏览器当前分享页面的截屏
Android 获取浏览器当前分享页面的截屏 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/BrowserScreenShotActivity 文中 ...
- Android -- 带你从源码角度领悟Dagger2入门到放弃
1,以前的博客也写了两篇关于Dagger2,但是感觉自己使用的时候还是云里雾里的,更不谈各位来看博客的同学了,所以今天打算和大家再一次的入坑试试,最后一次了,保证最后一次了. 2,接入项目 在项目的G ...
- Android -- 带你从源码角度领悟Dagger2入门到放弃(二)
1,接着我们上一篇继续介绍,在上一篇我们介绍了简单的@Inject和@Component的结合使用,现在我们继续以老师和学生的例子,我们知道学生上课的时候都会有书籍来辅助听课,先来看看我们之前的Stu ...
- Android - TabHost 与 Fragment 制作页面切换效果
Android - TabHost 与 Fragment 制作页面切换效果 Android API 19 , API 23 三个标签页置于顶端 效果图: 在文件BoardTabHost.java中定义 ...
- Android -- 带你从源码角度领悟Dagger2入门到放弃(一)
1,以前的博客也写了两篇关于Dagger2,但是感觉自己使用的时候还是云里雾里的,更不谈各位来看博客的同学了,所以今天打算和大家再一次的入坑试试,最后一次了,保证最后一次了. 2,接入项目 在项目的G ...
- Gitlab系列九之取消用户注册页面和删除用户
一.取消用户注册页面 Admin Area--->Settings--->Sign-up enabled(取消前面的勾)---save 二.删除用户 Users----Destroy(点他 ...
随机推荐
- leetcode@ [79/140] Trie树应用 Word Search / Word Search II
https://leetcode.com/problems/word-search/ class Solution { public: struct Trie{ Trie *next[]; bool ...
- 【noip2012】开车旅行
题意: 给n个点的海拔h[i](不同点海拔不同) 两点的距离为abs(h[i]-h[j]) 有a.b两人轮流开车(只能往下标大的地方开) a每次会开到里当前点第二近的点 b每次会开到离当前点最近的点( ...
- HDU-1402 A * B Problem Plus FFT(快速傅立叶变化)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1402 一般的的大数乘法都是直接模拟乘法演算过程,复杂度O(n^2),对于这题来说会超时.乘法的过程基本 ...
- HDU5739-Fantasia(tarjan求割点)
题意:给一个无向图n个点1~n,m条边,sigma(i*zi)%(1e9+7).zi是这个图删掉i点之后的价值.一个图的价值是所有连通子图的价值之和,连通图的价值是每个点的乘积. 题解:讲道理这题不算 ...
- Java之泛型练习
package cn.itcast.generics; import java.util.Comparator; import java.util.Iterator; import java.util ...
- A Tour of Go Methods continued
In fact, you can define a method on any type you define in your package, not just structs. You canno ...
- [iOS基础控件 - 5.3] 电台APP可滚动主界面(UIScrollView制作)
A.功能 1.上下可滚动的电台 2 x n 的图标集 2.顶部半透明标题 3.底部半透明功能按钮 B.实现思路 1.设置图标.启动画面 2.拖入UIScrollView,设置背景色 ( ...
- C# 条形码 生成函数 (Code 128 标准
C# 条形码 生成函数 (Code 128 标准参考:GB/T 18347-2001) 最近在做单据打印,发现客户要求用到条形码,在网上找了,发现只有一些条形码的标准,但打出来发现根本不能扫,还要加某 ...
- SQLite使用教程7 删除表
http://www.runoob.com/sqlite/sqlite-drop-table.html SQLite 删除表 SQLite 的 DROP TABLE 语句用来删除表定义及其所有相关数据 ...
- 利用sqlmap和burpsuite绕过csrf token进行SQL注入 (转)
问题:post方式的注入验证时遇到了csrf token的阻止,原因是csrf是一次性的,失效导致无法测试. 解决方案:Sqlmap配合burpsuite,以下为详细过程,参照国外牛人的blog(不过 ...