-1

关于这篇文章Get/pick an image from Android's built-in Gallery app programmatically

什么是R.layout.main((Button) findViewById(R.id.Button01))应该是什么?

因为内容视图不应该是手机图库吗?在这种情况下,它应该已经存在了。什么是按钮?

编辑:我正在以字符串的形式获取图像external/images/media/12。如何ImageView使用此字符串设置图像?

4

3 回答 3

1

您应该将“main.xml”添加到 res/layout(如果不存在!)并将此代码附加到它:

<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>
于 2013-10-20T06:36:44.027 回答
1

根据 Intent Action,intent.setAction(Intent.ACTION_GET_CONTENT);android 会自动将用户带到新的系统活动以选择文件。因此与此代码具有的按钮和布局无关。

于 2013-10-20T06:38:06.770 回答
0

使用此代码:

ImageView image = null;
Bitmap bm = BitmapFactory.decodeFile("Your image browse");      
image.setImageBitmap(bm);
于 2013-10-20T09:58:03.077 回答