详细的图文可以到我的百度经验去查看: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带头像的用户注册页面的更多相关文章

  1. 超详细的php用户注册页面填写信息完整实例(附源码)

    这篇文章主要介绍了一个超详细的php用户注册页面填写信息完整实例,内容包括邮箱自动匹配.密码强度验证以及防止表单重复等,小编特别喜欢这篇文章,推荐给大家. 注册页面是大多数网站必备的页面,所以很有必要 ...

  2. 实现android手机来电拦截系统页面弹出自定义页面特效

    如何实现android手机来电拦截系统页面弹出自定义页面特效, 首先:    我们需要注册一个监听来电的广播PhoneStateReceiver 类:其次:    在onReceive里面我们获取an ...

  3. JavaScript、CSS、JSP 实现用户注册页面与信息校验

    参考:http://blog.csdn.net/fightfaith/article/details/50277337 需求:实现用户注册页面并作出逻辑校验.要求: (1)完成注册页面样式如下: (2 ...

  4. Android 获取浏览器当前分享页面的截屏

    Android 获取浏览器当前分享页面的截屏 版权声明:本文为博主原创文章,未经博主允许不得转载. 微博:厉圣杰 源码:AndroidDemo/BrowserScreenShotActivity 文中 ...

  5. Android -- 带你从源码角度领悟Dagger2入门到放弃

    1,以前的博客也写了两篇关于Dagger2,但是感觉自己使用的时候还是云里雾里的,更不谈各位来看博客的同学了,所以今天打算和大家再一次的入坑试试,最后一次了,保证最后一次了. 2,接入项目 在项目的G ...

  6. Android -- 带你从源码角度领悟Dagger2入门到放弃(二)

    1,接着我们上一篇继续介绍,在上一篇我们介绍了简单的@Inject和@Component的结合使用,现在我们继续以老师和学生的例子,我们知道学生上课的时候都会有书籍来辅助听课,先来看看我们之前的Stu ...

  7. Android - TabHost 与 Fragment 制作页面切换效果

    Android - TabHost 与 Fragment 制作页面切换效果 Android API 19 , API 23 三个标签页置于顶端 效果图: 在文件BoardTabHost.java中定义 ...

  8. Android -- 带你从源码角度领悟Dagger2入门到放弃(一)

    1,以前的博客也写了两篇关于Dagger2,但是感觉自己使用的时候还是云里雾里的,更不谈各位来看博客的同学了,所以今天打算和大家再一次的入坑试试,最后一次了,保证最后一次了. 2,接入项目 在项目的G ...

  9. Gitlab系列九之取消用户注册页面和删除用户

    一.取消用户注册页面 Admin Area--->Settings--->Sign-up enabled(取消前面的勾)---save 二.删除用户 Users----Destroy(点他 ...

随机推荐

  1. Bzoj-2818 Gcd 欧拉函数

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2818 题意:给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x ...

  2. C# Asp.net中的AOP框架 Microsoft.CCI, Mono.Cecil, Typemock Open-AOP API, PostSharp -摘自网络 (可以利用反射 Attribute 进行面向切面编程 可以用在记录整个方法的Log方面)

    Both Microsoft.CCI and Mono.Cecil are low-level, and don't validate produced assemblies. It takes lo ...

  3. Android之指南针(电子罗盘)学习

    点我下载源码 5月12日更新到V5版:http://download.csdn.net/detail/weidi1989/5364243 今天,在小米的开源项目中下载了一个指南针源码学习了一下,感觉不 ...

  4. A Tour of Go Mutating Maps

    Insert or update an element in map m: m[key] = elem Retrieve an element: elem = m[key] Delete an ele ...

  5. 转载 asp.net中ViewState的用法详解

    转载原地址: http://www.jb51.net/article/73662.htm 在web窗体控件设置为runat = "server",这个控件会被附加一个隐藏的属性_V ...

  6. hdu 1520 (树形DP)

    dp[i][0]表示i不参加 dp[i][1]表示i参加 简单的树形dp #include<stdio.h> #include<string.h> #define N 6100 ...

  7. UINavgation日常小bug-有兴趣的朋友可以看看

    UINavgation日常 UINavgation 今天在做一个小Demo,发现一个Bug,挺有意思的,就是在你不断调用Navigation- (void)pushViewController:(UI ...

  8. JAVA使用EPoll来进行NIO处理的方法(转)

    JDK 6.0 以及JDK 5.0 update 9 的 nio支持epoll (仅限 Linux 系统 ),对并发idle connection会有大幅度的性能提升,这就是很多网络服务器应用程序需要 ...

  9. 关于写blog这件事

     事实上一直是挺喜欢写blog的.可是近期在写blog这件事上遇到或者開始思考一些问题了. 首先,写blog的动机.对于这个问题,我从自己的理解上得出下面几个原因: 写blog是对自己学到知识的一种总 ...

  10. js过滤前后空格

    页面中添加代码 String.prototype.trim=function() {    return this.replace(/(^\s*)|(\s*$)/g,'');} 调用:title.tr ...