2016-07-22 11 views
-2

私はAndroidプログラミングにとって全く新しいです。私はImageViewがコード化された関数の結果に応じて画像を変更したいと思っています。だから、ImageView関数

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:background="@drawable/bg"> 

    <ImageView 
     android:id="@+id/logo" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="top" 
    android:src="@drawable/logo"/> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/logo" 
     android:src="@drawable/server"/> 

    <ImageView 
     android:id="@+id/status" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent"/> 

、私はImageViewのを作るために何を書くべきちょうど自体が(私は「ステータス」ImageViewのを意味し、それは最後の一つだ)何かをしますか?クリックも押さない。

+0

ジャスト 'imageView.setImageBitmap()'や 'imageView.setImageResource呼び出します() ' –

+0

あなたは何をしたいですか?それは明らかではありません。 – Drv

+0

「クリックしない」とは、ImageViewの最初からイメージセットを(XMLで直接android:src = "@ drawable/image"を使用して)設定するか、コード行を必要とすることを意味しますimageView.setImageBitmap(...)/imageView.setImageResource(...)または、一定の時間が経過すると自動的に発生させますか、アプリ内のどこかで何かが起きたときに変更しますか? – LuigiPower

答えて

0

1)Drawableフォルダを右クリックし、既存のファイルを追加を選択して、コンピュータから画像を選択します。

2)次に、あなたのXAMLファイルであなたのImageViewの下の行を追加します:アンドロイド:背景= "描画可能/ NameOfThePictureThatYouJustAddedToTheDrawableFolder @"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/bg" > <ImageView android:id="@+id/logo" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:src="@drawable/logo"/> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/logo" android:src="@drawable/server"/> <ImageView android:id="@+id/status" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/NameOfThePictureThatYouJustAddedToTheDrawableFolder" />