Android 从库中添加图片

Android 从库中添加图片,android,Android,关于这个职位 R.layout.main和((按钮)findViewById(R.id.Button01))应该是什么 因为内容视图不应该是电话库吗?在这种情况下,它应该已经在那里了。按钮是什么 编辑:我以字符串的形式获取图像,表示external/images/media/12。如何使用此字符串设置图像视图的图像?您应该将“main.xml”添加到res/layout(如果不存在!) 并将此代码附加到其中: <RelativeLayout xmlns:android="http://sc

关于这个职位

R.layout.main
((按钮)findViewById(R.id.Button01))
应该是什么

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

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

您应该将“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>

根据Intent操作,
Intent.setAction(Intent.Action\u GET\u CONTENT)
android会自动将用户带到新系统活动中选择文件。因此与此代码的按钮和布局无关。

使用此代码:

ImageView image = null;
Bitmap bm = BitmapFactory.decodeFile("Your image browse");      
image.setImageBitmap(bm);