您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 图片选择器
  所属分类: Android
  开发工具:
  文件大小: 5mb
  下载次数: 0
  上传时间: 2016-02-18
  提 供 者: qq_31******
 详细说明: package com.example.administrator.application; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.GridView; import android.widget.TextView; import android.widget.Toast; import com.example.administrator.application.activity.CCwantPhotoBrowserActivity; import com.example.administrator.application.activity.CCwantSelectAlbumActivity; import com.example.administrator.application.adapter.CCwantPublishAdapter; import java.io.Serializable; import java.util.ArrayList; import java.util.List; public class Main2Activity extends Activity { /** * 打开相册选择activity */ private final int OPEN_SELECT_ALBUM=1; /** * 打开图片浏览器activity */ private final int OPEN_PHOTO_BROWSER=2; /** * 你选择的所有图片路径 */ private List mData=new ArrayList(); private GridView mGrvContent; private CCwantPublishAdapter mAdapter; private TextView mTxtSend; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); mAdapter=new CCwantPublishAdapter(this,mData); mGrvContent=(GridView)findViewById(R.id.grv_content); mGrvContent.setAdapter(mAdapter); mGrvContent.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { //如果点击了+则打开相册选择器,否则打开相片浏览界面 if(position==mAdapter.getMaxPosition()-1){ Intent intent=new Intent(Main2Activity.this,CCwantSelectAlbumActivity.class); startActivityForResult(intent, OPEN_SELECT_ALBUM); }else{ Intent intent=new Intent(Main2Activity.this,CCwantPhotoBrowserActivity.class); intent.putExtra("CCwantPhotoList",(Serializable) mData); intent.putExtra("CCwantPhotoPosition",(Serializable)position); startActivityForResult(intent, OPEN_PHOTO_BROWSER); } } }); mTxtSend=(TextView)findViewById(R.id.txt_send); mTxtSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < mData.size(); i++) { sb.append(mData.get(i) + "\n"); } Toast.makeText(getApplicationContext(), "" + sb.toString(), Toast.LENGTH_SHORT).show(); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); //处理选择图片后的返回值 if(requestCode==OPEN_SELECT_ALBUM){ if (resultCode == RESULT_OK) { Bundle bundle = data.getExtras(); List list=new ArrayList(); list.addAll(mData); list.addAll(bundle.getStringArrayList("result")); mData.clear(); mData.addAll(list); mAdapter.notifyDataSetChanged(); } } //处理图片浏览的返回值 if(requestCode==OPEN_PHOTO_BROWSER){ if (resultCode == RESULT_OK) { Bundle bundle = data.getExtras(); List list=bundle.getStringArrayList("result"); mData.clear(); mData.addAll(list); mAdapter.notifyDataSetChanged(); } } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: ImageSelect
 输入关键字,在本站1000多万海量源码库中尽情搜索: