所以,我對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,它是最後一個)?沒有點擊或按下。
就叫'imageView.setImageBitmap()'或'imageView.setImageResource ()' –
你想做什麼?一點也不清楚。 – Drv
「無法點擊或按下」意味着您需要從ImageView的開始處設置圖像(直接在XML中使用android:src =「@ drawable/image」)或者您想要代碼行imageView.setImageBitmap(...)/imageView.setImageResource(...)或者你想讓它在一段時間後自動發生,或者當你的應用程序中的其他任何地方發生什麼事情時你想讓它改變嗎? – LuigiPower