Android Activity详解

矫情吗;* 2023-07-04 12:58 47阅读 0赞

一、Activity概述

Activity,实现程序的交互。

Activity,代表手机或平板中的一屏。

Activity的4种状态:
在这里插入图片描述
Activity的生命周期:
在这里插入图片描述
更正:OnRestart应该接到Onstart方法。

二、创建、启动和关闭Activity

1、创建Activity

  1. 创建继承自Activity的Activity
  2. 重写需要的回调方法
  3. 设置要显示的视图

    //extends Activity,即步骤一
    public class DetailActivity extends Activity {

    1. //onCreate(),即步骤二
    2. @Override
    3. protected void onCreate(Bundle savedInstanceState) {
    4. super.onCreate(savedInstanceState);
    5. //setContentView,即步骤三
    6. setContentView(R.layout.activity_main);
    7. }

    }

创建了Activity后需要配置才能使用。即要在Manifests中添加此acitivity

  1. <activity android:name=".DetailActivity" > </activity>
  2. //在配置name属性时,如果配置的Activity与上面的包路径一样,直接.类名
  3. //如果是在上面包的子包中,则.子包序列加上类名

android提供的创建Activity的向导,步骤简单
要在某个包中创建Acitivity,则单击鼠标右键,选择“New”→“Activity”→“Empty Activity”→”Finish”,则完成了Activity的创建,并自动创建了布局文件,并进行了配置。

2、启动和关闭Activity

当创建和配置一个Activity后,它不会自动显示在屏幕上,需要我们启动它。

要启动Activity,分成两种情况:

  1. 入口Activity
  2. 其他Activity
① 入口Activity

要在AndroidManifest.xml中进行配置。

  1. <activity android:name=".MainActivity">
  2. <!--通过下面4句代码,可把该Acitivity配置成程序的入口-->
  3. <!--下面4句代码,是用来配置intent过滤器的。-->
  4. <intent-filter>
  5. <!--action标记:指定响应的动作名,这条代码把一个activity指定为程序的主体动向-->
  6. <action android:name="android.intent.action.MAIN" />
  7. <!--category标记:指定在什么环境下,动作会响应。这条代码可把某个Activity作为应用程序的启动项-->
  8. <category android:name="android.intent.category.LAUNCHER" />
  9. </intent-filter>
  10. </activity>

Activity需要通过Intent来表达自己的意图。

② 其他Activity

需要startActivity()方法来启动

例子:

  1. //单击按钮后,启动另一个Activity
  2. button.setOnClickListener(new View.OnClickListener() {
  3. @Override
  4. public void onClick(View view) {
  5. //此处不能使用this,因为此处使用了匿名内部类,若用this就会指向匿名内部类对象了。
  6. Intent intent=new Intent(MainActivity.this,DetailActivity.class);
  7. startActivity(intent);
  8. }
  9. });

关闭Activity
使用finish()方法。

如果通过finish方法关闭的不是主活动,则执行关闭后就会回到调用它的Activity中,否则回到主界面中。

刷新当前的Activity
调用下列代码

  1. onCreate(null);

三、启动和关闭Activity实例——模拟喜马拉雅忘记密码页面跳转功能。

  1. Intent intent =new Intent(MainActivity.this,另一个活动的名.class);

效果如下:
点击忘记密码,跳转至图二;点击×,跳转至图一

图一
图二

activity_main.xml文件

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:paddingBottom="@dimen/activity_vertical_margin"
  7. android:paddingLeft="@dimen/activity_horizontal_margin"
  8. android:paddingRight="@dimen/activity_horizontal_margin"
  9. android:paddingTop="@dimen/activity_vertical_margin"
  10. tools:context="com.mingrisoft.forgetpassword.MainActivity">
  11. <TextView
  12. android:layout_width="match_parent"
  13. android:layout_height="wrap_content"
  14. android:layout_marginBottom="40dp"
  15. android:gravity="center_horizontal"
  16. android:textSize="25sp"
  17. android:text="登录" />
  18. <ImageView
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:src="@drawable/q2"/>
  22. <TableRow
  23. android:layout_width="match_parent"
  24. android:layout_height="match_parent"
  25. android:layout_marginTop="25dp">
  26. <TextView
  27. android:layout_width="wrap_content"
  28. android:layout_height="wrap_content"
  29. android:layout_gravity="top"
  30. android:layout_marginLeft="10dp"
  31. android:textSize="20sp"
  32. android:text="账号"
  33. />
  34. <EditText
  35. android:layout_width="wrap_content"
  36. android:layout_height="wrap_content"
  37. android:layout_marginLeft="10dp"
  38. android:hint="邮箱或手机号"
  39. />
  40. </TableRow>
  41. <TableRow
  42. android:layout_width="match_parent"
  43. android:layout_height="match_parent"
  44. android:layout_marginTop="25dp">
  45. <TextView
  46. android:layout_width="wrap_content"
  47. android:layout_height="wrap_content"
  48. android:layout_gravity="top"
  49. android:layout_marginLeft="10dp"
  50. android:textSize="20sp"
  51. android:text="密码"
  52. />
  53. <EditText
  54. android:layout_width="wrap_content"
  55. android:layout_height="wrap_content"
  56. android:layout_marginLeft="10dp"
  57. android:hint="输入6~16位数字或字母"
  58. />
  59. </TableRow>
  60. <TableRow
  61. android:layout_width="match_parent"
  62. android:layout_height="match_parent"
  63. android:layout_marginTop="25dp">
  64. <Button
  65. android:layout_width="match_parent"
  66. android:layout_height="match_parent"
  67. android:layout_marginLeft="10dp"
  68. android:text="注册"
  69. />
  70. <Button
  71. android:layout_width="match_parent"
  72. android:layout_height="match_parent"
  73. android:layout_marginLeft="10dp"
  74. android:text="登录"
  75. android:background="#f4b144"
  76. />
  77. </TableRow>
  78. <TextView
  79. android:text="忘记密码?"
  80. android:gravity="right"
  81. android:layout_margin="10dp"
  82. android:id="@+id/forget"/>
  83. </TableLayout>

MainActivity.java文件

  1. package com.mingrisoft.forgetpassword;
  2. import android.content.Intent;
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.TextView;
  7. public class MainActivity extends ActionBarActivity {
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. //使该布局文件就会跟这个activity绑定在一起
  12. setContentView(R.layout.activity_main);
  13. TextView textView= (TextView) findViewById(R.id.forget);
  14. //设置文本框单击事件监听器
  15. textView.setOnClickListener(new View.OnClickListener() {
  16. @Override
  17. public void onClick(View view) {
  18. //Intent表意图
  19. Intent intent=new Intent(MainActivity.this,PassWord.class);
  20. //启动另一个Activity
  21. startActivity(intent);
  22. }
  23. });
  24. }
  25. }

activity_password.xml文件

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:paddingTop="10dp"
  6. >
  7. <TableRow>
  8. <ImageButton
  9. android:id="@+id/close"
  10. android:layout_width="15dp"
  11. android:layout_height="15dp"
  12. android:scaleType="centerCrop"
  13. android:layout_marginLeft="20dp"
  14. android:layout_marginRight="120dp"
  15. android:src="@drawable/close2"
  16. android:background="#0000" />
  17. <TextView
  18. android:layout_width="wrap_content"
  19. android:layout_height="match_parent"
  20. android:layout_gravity="center_horizontal"
  21. android:text="找回密码"
  22. android:textColor="#161615"
  23. android:textSize="15sp"
  24. />
  25. </TableRow>
  26. <TextView
  27. android:layout_margin="20dp"
  28. android:layout_width="wrap_content"
  29. android:layout_height="wrap_content"
  30. android:text="你的邮箱或手机号"/>
  31. <EditText
  32. android:layout_margin="20dp"
  33. android:layout_width="wrap_content"
  34. android:layout_height="wrap_content"
  35. android:hint="请输入邮箱或手机号"/>
  36. <Button
  37. android:layout_margin="20dp"
  38. android:layout_width="wrap_content"
  39. android:layout_height="wrap_content"
  40. android:text="提交"
  41. android:background="#ec9640"/>
  42. </TableLayout>

PassWord.java文件

  1. package com.mingrisoft.forgetpassword;
  2. import android.app.Activity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.ImageButton;
  7. /** * Created by Asus on 2020/2/13. */
  8. public class PassWord extends Activity{
  9. @Override
  10. protected void onCreate(Bundle savedInstanceState) {
  11. super.onCreate(savedInstanceState);
  12. setContentView(R.layout.activity_password);
  13. ImageButton imageButton= (ImageButton) findViewById(R.id.close);
  14. imageButton.setOnClickListener(new View.OnClickListener() {
  15. @Override
  16. public void onClick(View view) {
  17. //返回上一界面
  18. finish();
  19. }
  20. });
  21. }
  22. }

不要忘了manifests哦!

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.mingrisoft.forgetpassword">
  4. <application
  5. android:allowBackup="true"
  6. android:icon="@mipmap/ic_launcher"
  7. android:label="@string/app_name"
  8. android:supportsRtl="true"
  9. android:theme="@style/AppTheme">
  10. <activity android:name=".MainActivity">
  11. <intent-filter>
  12. <action android:name="android.intent.action.MAIN" />
  13. <category android:name="android.intent.category.LAUNCHER" />
  14. </intent-filter>
  15. </activity>
  16. <activity android:name=".PassWord"></activity>
  17. </application>
  18. </manifest>

四、使用Bundle在Activity之间交换数据

什么是Bundle?
Bundle可以理解为键值对的组合,读取时通过key找到value值。
在这里插入图片描述

在Android中,我们把数据存放在Bundle当中,把要携带的数据保存到Intent中,再启动Activity。流程图如下:
在这里插入图片描述

实例:模拟淘宝的填写并显示收获地址的功能。

效果如下:
在这里插入图片描述

在这里插入图片描述

activity_main.xml文件

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:orientation="vertical"
  7. android:paddingBottom="@dimen/activity_vertical_margin"
  8. android:paddingLeft="@dimen/activity_horizontal_margin"
  9. android:paddingRight="@dimen/activity_horizontal_margin"
  10. android:paddingTop="@dimen/activity_vertical_margin"
  11. android:layout_margin="10dp"
  12. tools:context="com.mingrisoft.taobaoadress.MainActivity">
  13. <TextView
  14. android:layout_width="wrap_content"
  15. android:layout_height="wrap_content"
  16. android:layout_gravity="center_horizontal"
  17. android:textSize="20sp"
  18. android:text="收货地址管理" />
  19. <EditText
  20. android:id="@+id/et_site1"
  21. android:layout_width="match_parent"
  22. android:layout_height="0dp"
  23. android:hint="请输入所在地区"
  24. android:layout_weight="1" />
  25. <EditText
  26. android:id="@+id/et_site2"
  27. android:layout_width="match_parent"
  28. android:layout_height="0dp"
  29. android:hint="请输入街道"
  30. android:layout_weight="1" />
  31. <EditText
  32. android:id="@+id/et_site3"
  33. android:layout_width="match_parent"
  34. android:layout_height="0dp"
  35. android:hint="请输入详细地址"
  36. android:layout_weight="1" />
  37. <EditText
  38. android:id="@+id/et_site4"
  39. android:layout_width="match_parent"
  40. android:layout_height="0dp"
  41. android:hint="请输入收件人姓名"
  42. android:layout_weight="1" />
  43. <EditText
  44. android:id="@+id/et_site5"
  45. android:layout_width="match_parent"
  46. android:layout_height="0dp"
  47. android:hint="请输入收件人联系电话"
  48. android:layout_weight="1" />
  49. <EditText
  50. android:id="@+id/et_site6"
  51. android:layout_width="match_parent"
  52. android:layout_height="0dp"
  53. android:hint="请输入邮箱"
  54. android:layout_weight="1" />
  55. <Button
  56. android:id="@+id/button"
  57. android:layout_width="wrap_content"
  58. android:layout_height="0dp"
  59. android:layout_gravity="right"
  60. android:layout_marginTop="30dp"
  61. android:text="保存"
  62. android:background="#f1a945"
  63. android:layout_weight="1" />
  64. </LinearLayout>

MainActivity.java文件

  1. package com.mingrisoft.taobaoadress;
  2. import android.content.Intent;
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.Button;
  7. import android.widget.EditText;
  8. import android.widget.Toast;
  9. public class MainActivity extends ActionBarActivity {
  10. @Override
  11. protected void onCreate(Bundle savedInstanceState) {
  12. super.onCreate(savedInstanceState);
  13. setContentView(R.layout.activity_main);
  14. //获取保存按钮
  15. Button button= (Button) findViewById(R.id.button);
  16. //设置单击事件监听器
  17. button.setOnClickListener(new View.OnClickListener() {
  18. @Override
  19. public void onClick(View view) {
  20. //获取数据
  21. String site1=((EditText)findViewById(R.id.et_site1)).getText().toString();
  22. String site2=((EditText)findViewById(R.id.et_site2)).getText().toString();
  23. String site3=((EditText)findViewById(R.id.et_site3)).getText().toString();
  24. String name=((EditText)findViewById(R.id.et_site4)).getText().toString();
  25. String phone=((EditText)findViewById(R.id.et_site5)).getText().toString();
  26. String email=((EditText)findViewById(R.id.et_site6)).getText().toString();
  27. //判断信息是否填完整
  28. if(!"".equals(site1)&&!"".equals(phone)&&!"".equals(site3)&&
  29. !"".equals(name)&&!"".equals(phone)&&!"".equals(email))
  30. {
  31. //若完整,创建一个Intent对象
  32. Intent intent=new Intent(MainActivity.this,ShowAdress.class);
  33. //创建一个Bundle对象,将数据放入Bundle中
  34. Bundle bundle=new Bundle();
  35. bundle.putCharSequence("name",name);
  36. bundle.putCharSequence("phone",phone);
  37. bundle.putCharSequence("site1",site1);
  38. bundle.putCharSequence("site2",site2);
  39. bundle.putCharSequence("site3",site3);
  40. //将Bundle给intent
  41. intent.putExtras(bundle);
  42. //启动另一个活动。
  43. startActivity(intent);
  44. }
  45. else {
  46. Toast.makeText(MainActivity.this, "请将收货地址填写完整", Toast.LENGTH_SHORT).show();
  47. }
  48. }
  49. });
  50. }
  51. }

ShowAdress.xml文件

  1. package com.mingrisoft.taobaoadress;
  2. import android.content.Intent;
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.os.Bundle;
  5. import android.widget.TextView;
  6. public class ShowAdress extends ActionBarActivity {
  7. @Override
  8. protected void onCreate(Bundle savedInstanceState) {
  9. super.onCreate(savedInstanceState);
  10. setContentView(R.layout.activity_show_adress);
  11. //获取Intent
  12. Intent intent=getIntent();
  13. //通过Intent获取Bundle
  14. Bundle bundle=intent.getExtras();
  15. //提取Bundle中的数据
  16. String name=bundle.getString("name");
  17. String phone=bundle.getString("phone");
  18. String site=bundle.getString("site1")+bundle.getString("site2")+bundle.getString("site3");
  19. //获取xml中的文本框
  20. TextView tv_name= (TextView) findViewById(R.id.name);
  21. TextView tv_phone= (TextView) findViewById(R.id.phone);
  22. TextView tv_site= (TextView) findViewById(R.id.site);
  23. //将数据放入文本框中
  24. tv_name.setText(name);
  25. tv_phone.setText(phone);
  26. tv_site.setText(site);
  27. }
  28. }

activity_showadress.xml文件

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:paddingBottom="@dimen/activity_vertical_margin"
  7. android:paddingLeft="@dimen/activity_horizontal_margin"
  8. android:paddingRight="@dimen/activity_horizontal_margin"
  9. android:paddingTop="@dimen/activity_vertical_margin"
  10. android:layout_margin="10dp"
  11. tools:context="com.mingrisoft.taobaoadress.ShowAdress">
  12. <TextView
  13. android:id="@+id/top"
  14. android:layout_width="wrap_content"
  15. android:layout_height="wrap_content"
  16. android:layout_gravity="center_horizontal"
  17. android:textSize="20sp"
  18. android:text="收货地址管理" />
  19. <TextView
  20. android:layout_width="wrap_content"
  21. android:layout_height="wrap_content"
  22. android:id="@+id/name"
  23. android:layout_below="@+id/top"
  24. />
  25. <TextView
  26. android:layout_width="wrap_content"
  27. android:layout_height="wrap_content"
  28. android:layout_alignParentRight="true"
  29. android:id="@+id/phone"
  30. android:layout_below="@+id/top"
  31. />
  32. <TextView
  33. android:layout_width="wrap_content"
  34. android:layout_height="wrap_content"
  35. android:id="@+id/site"
  36. android:layout_below="@id/name"
  37. />
  38. </RelativeLayout>

别忘了manifests哦!

五、调用另一个Activity并返回结果

使用startActivityForResult()方法,启动另一个Activity,在另一个Activity中选择一些内容之后,关闭新启动的Activit时,将选择结果返回到原来的Activity中。

方法的基本格式:

  1. public void startActivityForResult(Intent intent,int requestCode)
  2. //intent用来指定想启动的Activity,第二个参数为指定请求码,标识请求的来源。如0x007。
实例:模拟喜马拉雅FM选择头像功能。

android:horizontalSpacing:用于控制字体之间的水平间距。
效果如下:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

activity_main.xml文件

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:orientation="vertical"
  7. android:paddingBottom="@dimen/activity_vertical_margin"
  8. android:paddingLeft="@dimen/activity_horizontal_margin"
  9. android:paddingRight="@dimen/activity_horizontal_margin"
  10. android:paddingTop="@dimen/activity_vertical_margin"
  11. android:background="@drawable/timg"
  12. tools:context="com.mingrisoft.changetou.MainActivity">
  13. <ImageView
  14. android:id="@+id/imageView"
  15. android:layout_width="80dp"
  16. android:layout_height="80dp"
  17. android:layout_gravity="center_horizontal"
  18. android:src="@drawable/t1" />
  19. <Button
  20. android:id="@+id/btn"
  21. android:layout_width="wrap_content"
  22. android:layout_height="40dp"
  23. android:layout_gravity="center_horizontal"
  24. android:text="选择头像"
  25. />
  26. </LinearLayout>

MainActivity.java文件

  1. package com.mingrisoft.changetou;
  2. import android.content.Intent;
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.Button;
  7. import android.widget.ImageView;
  8. public class MainActivity extends ActionBarActivity {
  9. @Override
  10. //活动返回
  11. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  12. super.onActivityResult(requestCode, resultCode, data);
  13. if(requestCode==0x11&&resultCode==0x11) //如果返回
  14. {
  15. //获取Bundle
  16. Bundle bundle=data.getExtras();
  17. //获取此时头像
  18. int imageId=bundle.getInt("imageId");
  19. //获取xml中的ImageView
  20. ImageView imageView= (ImageView) findViewById(R.id.imageView);
  21. //将数据放入ImageView框中
  22. imageView.setImageResource(imageId);
  23. }
  24. }
  25. @Override
  26. protected void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_main);
  29. Button button= (Button) findViewById(R.id.btn);
  30. button.setOnClickListener(new View.OnClickListener() {
  31. @Override
  32. public void onClick(View view) {
  33. Intent intent=new Intent(MainActivity.this,Choose.class);
  34. //请求码为0x11
  35. startActivityForResult(intent,0x11);
  36. }
  37. });
  38. }
  39. }

activity_choose.xml文件

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:tools="http://schemas.android.com/tools"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:paddingBottom="@dimen/activity_vertical_margin"
  7. android:paddingLeft="@dimen/activity_horizontal_margin"
  8. android:paddingRight="@dimen/activity_horizontal_margin"
  9. android:paddingTop="@dimen/activity_vertical_margin"
  10. tools:context="com.mingrisoft.changetou.choose">
  11. <!-- 网格布局管理器 -->
  12. <GridView
  13. android:layout_width="match_parent"
  14. android:layout_height="match_parent"
  15. android:id="@+id/gridView"
  16. android:layout_marginTop="10dp"
  17. android:horizontalSpacing="3dp"
  18. android:numColumns="4"
  19. ></GridView>
  20. </RelativeLayout>

Choose.java文件

  1. package com.mingrisoft.changetou;
  2. import android.content.Intent;
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.view.ViewGroup;
  7. import android.widget.AdapterView;
  8. import android.widget.BaseAdapter;
  9. import android.widget.GridView;
  10. import android.widget.ImageView;
  11. public class Choose extends ActionBarActivity {
  12. public int imageId[]=new int[]{
  13. R.drawable.t2,R.drawable.t3,R.drawable.t4,
  14. R.drawable.t5
  15. };
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. setContentView(R.layout.activity_choose);
  20. //获取网格布局管理器
  21. GridView gridView= (GridView) findViewById(R.id.gridView);
  22. //设置适配器
  23. BaseAdapter adapter=new BaseAdapter() {
  24. @Override
  25. public int getCount() {
  26. return imageId.length;
  27. }
  28. @Override
  29. public Object getItem(int i) {
  30. return i;
  31. }
  32. @Override
  33. public long getItemId(int i) {
  34. return i;
  35. }
  36. @Override
  37. public View getView(int position, View view, ViewGroup viewGroup) {
  38. ImageView imageView;
  39. //如果没有选择
  40. if(view==null)
  41. {
  42. imageView=new ImageView(Choose.this);
  43. imageView.setAdjustViewBounds(true);
  44. imageView.setMaxWidth(158);
  45. imageView.setMaxHeight(150);
  46. imageView.setPadding(5,5,5,5);
  47. }
  48. else
  49. {
  50. imageView=(ImageView)view;
  51. }
  52. //改变图片
  53. imageView.setImageResource(imageId[position]);
  54. return imageView;
  55. }
  56. };
  57. gridView.setAdapter(adapter);
  58. gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  59. @Override
  60. public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
  61. Intent intent=getIntent();
  62. Bundle bundle=new Bundle();
  63. bundle.putInt("imageId",imageId[i]);
  64. intent.putExtras(bundle);
  65. setResult(0x11,intent);
  66. //返回上一级
  67. finish();
  68. }
  69. });
  70. }
  71. }

发表评论

表情:
评论列表 (有 0 条评论,47人围观)

还没有评论,来说两句吧...

相关阅读