Back to project page Android-Display-Images-from-SD-Card-Tutorial.
The source code is released under:
Apache License
If you think the Android project Android-Display-Images-from-SD-Card-Tutorial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.androidbegin.sdimagetutorial; /* w w w . j a v a 2s. com*/ import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; public class LazyAdapter extends BaseAdapter { // Declare variables private Activity activity; private String[] data; private String[] name; private static LayoutInflater inflater = null; public ImageLoader imageLoader; public LazyAdapter(Activity a, String[] d, String[] n) { activity = a; data = d; name = n; inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageLoader = new ImageLoader(activity.getApplicationContext()); } public int getCount() { return data.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { View vi = convertView; if (convertView == null) vi = inflater.inflate(R.layout.gridview_item, null); // Locate the TextView in item.xml TextView text = (TextView) vi.findViewById(R.id.text); // Locate the ImageView in item.xml ImageView image = (ImageView) vi.findViewById(R.id.image); // Capture position and set to the TextView text.setText(name[position]); // Capture position and set to the ImageView imageLoader.DisplayImage(data[position], image); return vi; } }