Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show images in list view that are stored in my SD Card particular location
    primarykey
    data
    text
    <p>I have created an app in which i had use SPenSDK to create image using canvasView. Once i create an images in the canvas view, i save the image in the SD Card <strong>"/mnt/sdcard/SmemoExample"</strong> location. Now I want to display all the images that are stores here <strong>"/mnt/sdcard/SmemoExample"</strong> in my ListView.</p> <p>But i am not able to find any solution for that. So please help to solve this out. If possible with an examples.</p> <p><strong>List_view.xml file</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"/&gt; &lt;Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Clear Cache"/&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>item.xml file</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;ImageView android:id="@+id/image" android:layout_width="50dip" android:layout_height="50dip" android:src="@drawable/ic_launcher" android:scaleType="centerCrop"/&gt; &lt;TextView android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="left|center_vertical" android:textSize="20dip" android:layout_marginLeft="10dip"/&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>java code</strong></p> <pre><code>public class ListActivity extends Activity { private String[] mFileStrings; private File[] listFile; ListView list; ImageAdapter adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); File file = new File(CanvasActivity.DEFAULT_APP_IMAGEDATA_DIRECTORY); if (file.isDirectory()) { listFile = file.listFiles(); mFileStrings = new String[listFile.length]; for (int i = 0; i &lt; listFile.length; i++) { mFileStrings[i] = listFile[i].getAbsolutePath(); } } list = (ListView) findViewById(R.id.list); adapter = new ImageAdapter(this, mFileStrings); list.setAdapter(adapter); } public class ImageAdapter extends BaseAdapter { private Activity activity; private String[] data; private LayoutInflater inflater=null; public ImageLoader imageLoader; public ImageAdapter(Activity a, String[] d) { activity = a; data=d; 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.item, null); TextView text=(TextView)vi.findViewById(R.id.text);; ImageView image=(ImageView)vi.findViewById(R.id.image); text.setText("item "+position); imageLoader.DisplayImage(data[position], image); return vi; } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload