-1

In regards to this post Get/pick an image from Android's built-in Gallery app programmatically

What is R.layout.main and ((Button) findViewById(R.id.Button01)) supposed to be?

Because shouldnt the content view be the phones gallery? In whcih case it should already be there. And what is the button?

EDIT: I am getting the image in the form of a string that says external/images/media/12. How can I set the image of an ImageView using this string?

Community
  • 1
  • 1
Ogen
  • 6,499
  • 7
  • 58
  • 124

3 Answers3

1

you should add "main.xml" to res/layout (if not exist!) and append this code to it :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >    

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="43dp"
    android:text="Button" />

 </RelativeLayout>
javad
  • 833
  • 14
  • 37
1

According to the Intent Action, intent.setAction(Intent.ACTION_GET_CONTENT); android automatically takes the user to new system activity to choose a file. so not related to button and layout that this code have.

Majid Daeinejad
  • 1,037
  • 8
  • 19
0

use this code:

ImageView image = null;
Bitmap bm = BitmapFactory.decodeFile("Your image browse");      
image.setImageBitmap(bm);
javad
  • 833
  • 14
  • 37