Wednesday, April 10, 2013

[android-developers] dynamic image display

Hi I need to have a folder where images are downloaded. Then iterate through the contents of that folder to show images one by one for pre set time period. My screen is divided into3 parts. in 1st row are 2 columns- 1> list view and 2> image view 2nd row image view.Hi, My main focus is on displaying the images.my issue is how to create the image view, since the image resources are not in res folder of android, it is determined at run time. ican not place image into image view with android:src="@drawable/android"tag


public void getFromSdcard()
    {
       
        File file=  new File(android.os.Environment.getExternalStorageDirectory(),"serviceMobile2");
        Toast.makeText(getBaseContext(), "file printer",Toast.LENGTH_SHORT).show();
        if (file.isDirectory())
        {
            listFile = file.listFiles();


            for (int i = 0; i < listFile.length; i++)
            {
                mFileStrings[i] = listFile[i].getAbsolutePath();
                f.add(listFile[i].getAbsolutePath());
                System.out.println("...................................."+mFileStrings[i]);
                Toast.makeText(getBaseContext(), mFileStrings[i],
                        Toast.LENGTH_SHORT).show();
            Bitmap bitmap = BitmapFactory.decodeFile(listFile[i].getAbsolutePath());
            ImageView iv= (ImageView) findViewById(R.id.imageView2);
            iv.setImageBitmap(bitmap);
            }
        }
       
          
    }











xml file is->

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:stretchColumns="*" android:background="#ffffff">
    <!-- Row 1 with single column -->
     <TableRow
         android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:gravity="center_horizontal">
    <EditText
    android:id="@+id/personal_contacts"
    android:layout_width="200dip"
    android:layout_height="wrap_content"
    android:hint="number"
    android:inputType="number"
    android:imeOptions="actionSend" />
    <TableRow
         android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:gravity="center_horizontal">
     <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="Save" />
     </TableRow>
      <TableRow
         android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:gravity="center_horizontal">
    <Button
        android:id="@+id/button2"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="Delete" />
    </TableRow>
    </TableRow>
    <TableRow
         android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:gravity="center_horizontal">
      <ListView
        android:id="@+id/list2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>
      <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />
   
     </TableRow> 
         <TableRow
         android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:gravity="center_horizontal">
      <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />
      </TableRow>
    </TableLayout>

I ran the debugger. control does not go into if (file.isDirectory()) ?????????????



--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment