ITeye博客

Android Tutorial(1)Simple Cursor Adapter and ListView

sillycat · 2013-03-22 05:35 · Mobile Platform · 移动开发 · Markdown

Android Tutorial(1)Simple Cursor Adapter and ListView ListActivity is actually a subclass of the Activity class that includes strategies where you can attach ListAdapters. 1. Prepare the files First Create a XML file from Android ---> Android XML Layout File Place Layouts ---> RelativeLayout and change the right id. Forget of the first steps, I should start from creating the activity class that will automatically create the XML. Create the activity class file from Android ----> Android Activity Create a Android -----> Android XML File 2. Using the Graphical Layout Draw the List page with these XML I feel good to directly use the Graphical tools. It works. All the source codes are in EasyRestClientAndroid. Next steps, I am going to figure out how to deal with pagination and load picture from URL. 3. Load the ImageView from URL Here is the easiest way to get ImageView from URL, maybe in the future I will think about how to cache them. ImageView t4 = (ImageView) view.findViewById(R.id.product_image); URL url = null; Bitmap bmp = null; try { url = new URL(item.getProductImageURL()); bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } t4.setImageBitmap(bmp); return view; References: http://vimaltuts.com/android-tutorials/simple-cursor-adapter-and-listview http://www.javasrilankansupport.com/2012/05/android-listview-example-with-image-and.html http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html Complex way to load the URL and place in Cache http://www.androidhive.info/2012/07/android-loading-image-from-url-http/ Pagination http://p-xr.com/android-tutorial-dynamicaly-load-more-items-to-the-listview-never-ending-list/

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。