日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ImageView相关

發布時間:2023/12/10 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ImageView相关 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ImageViewActivity.java

package src.com;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class ImageViewActivity extends Activity {

/* 聲明 Button、ImageView對象 */
private ImageView mImageView01;
private ImageView mImageView02;
private Button mButton01;
private Button mButton02;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

/* 取得 Button、ImageView對象 */
mImageView01 = (ImageView) findViewById(R.id.myImageView1);
mImageView02 = (ImageView) findViewById(R.id.myImageView2);
mButton01 = (Button) findViewById(R.id.myButton1);
mButton02 = (Button) findViewById(R.id.myButton2);

/* 設置ImageView背景圖 */
mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.right));
mImageView02.setImageDrawable(getResources().getDrawable(R.drawable.oa));

/* 用OnClickListener事件來啟動 */
mButton01.setOnClickListener(new Button.OnClickListener(){

@Override
public void onClick(View v) {
/* 當啟動后,ImageView立刻換背景圖 */
mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.right));
}

});

mButton02.setOnClickListener(new Button.OnClickListener(){

@Override
public void onClick(View v) {
/* 當啟動后,ImageView立刻換背景圖 */
mImageView01.setImageDrawable(getResources().getDrawable(R.drawable.left));
}

});
}
}

?

main.xml

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/widget34" >"

<!-- 建立第一個ImageView -->
<ImageView
android:id="@+id/myImageView1"
android:layout_width="320px"
android:layout_height="280px"
android:layout_x="0px"
android:layout_y="36px" />
<!-- 建立第二個ImageView -->
<ImageView
android:id="@+id/myImageView2"
android:layout_width="104px"
android:layout_height="157px"
android:layout_x="101px"
android:layout_y="119px" />
<!-- 建立第一個Button -->
<Button
android:id="@+id/myButton1"
android:layout_width="105px"
android:layout_height="66px"
android:text="pic1"
android:layout_x="9px"
android:layout_y="356px" />
<!-- 建立第二個Button -->
<Button
android:id="@+id/myButton2"
android:layout_width="105px"
android:layout_height="66px"
android:text="pic2"
android:layout_x="179px"
android:layout_y="356px" />

</AbsoluteLayout>

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的ImageView相关的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。