Download the album list and source code for android (4). Download the android source code

Source: Internet
Author: User

Download the album list and source code for android (4). Download the android source code

The functions of this project are as follows:
Obtain the mobile phone album. Click each album to go to the image list page of the album. You can select multiple images on the image list page, and then go to the selected image page, this interface allows you to upload the selected image.
The biggest feature of this project:
1. Get the album list. At present, there are few items on the network to get the album. This article describes how to get the album.
2. Use Android-Universal-Image-Loader integration framework-third-party jar packages to load local images. Developers familiar with this jar package are certainly familiar with it. This jar package is very powerful, in addition to obtaining network images, local images are also supported. Third-party jar can be referenced to effectively solve OOM exceptions.

The addresses of the above three blog posts are as follows:
How to obtain the album list for android and download the source code (1)
How to obtain the album list for android and download the source code (2)
How to obtain the album list for android and download the source code (3)

This article continues with the content of the above three blog posts. The following shows the picture in the selected album, and the Activity jumps to the page of the selected picture, it is to load the selected image to the interface for display, so that developers can easily process the selected image, such as uploading, and further develop according to their own needs.
The code for the Activity class is as follows:

Public class SelectedImagesActivity extends Activity implements OnClickListener {private GridView gridView; private TextView back, OK; private ArrayList <PhotoUpImageItem> arrayList; // stores the selected image list private SelectedImagesAdapter adapter; // adapter @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); requestWindowFeature (Window. FEATURE_NO_TITLE); setContentView (R. l Ayout. selected_images_grid); init (); setclickListener () ;}@ SuppressWarnings ("unchecked") private void init () {gridView = (GridView) findViewById (R. id. selected_images_gridv); back = (TextView) findViewById (R. id. back); OK = (TextView) findViewById (R. id. sure); arrayList = (ArrayList <PhotoUpImageItem>) getIntent (). getSerializableExtra ("selectIma"); adapter = new SelectedImagesAdapter (SelectedImagesAc Tietong. this, arrayList); gridView. setAdapter (adapter);} private void setclickListener () {back. setOnClickListener (this); OK. setOnClickListener (this); gridView. setOnItemClickListener (new OnItemClickListener () {@ Override public void onItemClick (AdapterView <?> Parent, View view, int position, long id) {}}) ;}@ Override protected void onDestroy () {super. onDestroy () ;}@ Override public void onClick (View v) {switch (v. getId () {case R. id. back: finish (); break; case R. id. sure: Toast. makeText (SelectedImagesActivity. this, "upload and other operations, developers can handle it themselves", Toast. LENGTH_LONG ). show (); break ;}}}

The Activity code is very simple. The following shows the adapter code:

Public class extends BaseAdapter {private ArrayList <PhotoUpImageItem> arrayList; private LayoutInflater layoutInflater; private ImageLoader imageLoader; displayprivate imageoptions options; public Context, ArrayList <PhotoUpImageItem> arrayList) {this. arrayList = arrayList; layoutInflater = LayoutInflater. from (context); imageLoader = ImageLoader. getInstance (); // use DisplayImageOption. builder () Create DisplayImageOptions options = new DisplayImageOptions. builder (). showStubImage (R. drawable. album_default_loading_pic) // sets the image displayed during image download. showImageForEmptyUri (R. drawable. album_default_loading_pic) // sets the image to be displayed when the image Uri is null or incorrect. showImageOnFail (R. drawable. album_default_loading_pic) // sets the picture to be incorrectly displayed during image loading or decoding. cacheInMemory (true) // sets whether the downloaded image is cached in memory. cacheOnDisc (true) // sets whether the downloaded image is cached on the SD card //. displayer (new RoundedBitmapDisplayer (20) // set it to a rounded image. bitmapConfig (Config. ARGB_8888 ). imageScaleType (ImageScaleType. IN_SAMPLE_INT ). build (); // create a configured DisplayImageOption object} @ Override public int getCount () {return arrayList. size () ;}@ Override public Object getItem (int position) {return arrayList. get (position) ;}@ Override public long getItemId (int position) {return position ;}@ Override public View getView (int position, View convertView, ViewGroup parent) {Holder holder; if (convertView = null) {convertView = layoutInflater. inflate (R. layout. selected_images_adapter_item, parent, false); holder = new Holder (); holder. imageView = (ImageView) convertView. findViewById (R. id. selected_image_item); convertView. setTag (holder);} else {holder = (Holder) convertView. getTag ();} imageLoader. displayImage ("file: //" + arrayList. get (position ). getImagePath (), holder. imageView, options); return convertView;} class Holder {ImageView imageView ;}}

The adapter code is also very simple. You can use the image loader-third-party jar package for implementation. Click the OK button to perform subsequent development.
So far, the entire project has been described. If you have any questions or find any mistakes in the text, please do not hesitate to give me your advice! Thank you very much! At the same time, due to my limited level, if there are any errors in the blog, please forgive me. Please criticize and correct me! [Handshake]

Blog link:
How to obtain the album list for android and download the source code (1)
How to obtain the album list for android and download the source code (2)
How to obtain the album list for android and download the source code (3)

Source code download

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.