-1

この投稿に関してプログラムで Android の組み込みギャラリー アプリから画像を取得/選択する

何が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 に答える