9久久伊人精品综合,亚洲一区精品视频在线,成 人免费va视频,国产一区二区三区黄网,99国产精品永久免费视频,亚洲毛片多多影院,精品久久久无码人妻中文字幕,无码国产欧美一区二区三区不卡
學(xué)習(xí)啦>學(xué)習(xí)電腦>電腦技巧>

android5.0程序開發(fā)的圖片按鈕ImageButton使用教程

時(shí)間: 本達(dá)868 分享

  在android5.0程序開發(fā)中,你知道圖片按鈕控件ImageButton怎么使用嗎?下面是學(xué)習(xí)啦小編給大家整理的一些有關(guān)android5.0程序開發(fā)的圖片按鈕ImageButton使用教程,希望對大家有幫助!

  android5.0程序開發(fā)的圖片按鈕ImageButton使用教程

  啟動eclipse程序,新建一android5.0工程文件ImageButtonDemo。

  將圖片素材導(dǎo)入到drawable目錄中,可以復(fù)制圖片文件,在drawable目錄中進(jìn)行粘貼。注意圖片文件名不能以數(shù)字開頭,否則出錯(cuò)。

  在activity_main.xml文件中加入一個(gè)TextView文本控件和兩個(gè)ImageButton圖片按鈕控件。

  <?xml version="1.0" encoding="utf-8"?>

  <LinearLayout xmlns:android="hp://schemas.android.apk/res/android"

  android:orientation="vertical"

  android:layout_width="fill_parent"

  android:layout_height="fill_parent"

  >

  <TextView

  android:id="@+id/TextView01"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content">

  </TextView>

  <ImageButton

  android:id="@+id/ImageButton01"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:background="@drawable/a">

  </ImageButton>

  <ImageButton

  android:id="@+id/ImageButton02"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:background="@drawable/c">

  </ImageButton>

  </LinearLayout>

  再雙擊打開MainActivity.java文件,導(dǎo)入TextView控件類、ImageButton控件類聲明。

  import android.widget.TextView;

  import android.widget.ImageButton;

  在程序中加入文本控件和兩個(gè)ImageButton控件的引用代碼。

  final TextView textview1=(TextView)findViewById(R.id.TextView01);

  final ImageButton imagebutton1=(ImageButton)findViewById(R.id.ImageButton01);

  final ImageButton imagebutton2=(ImageButton)findViewById(R.id.ImageButton02);

  分別添加imagebutton1和imagebutton2的執(zhí)行代碼。點(diǎn)擊圖片按鈕會改變按鈕。

  imagebutton1.setOnClickListener(new OnClickListener(){

  @Override

  public void onClick(View v) {

  textview1.setText("點(diǎn)擊了第一個(gè)圖片按鈕");

  imagebutton1.setImageDrawable(getResources().getDrawable(R.drawable.b));

  imagebutton2.setImageDrawable(getResources().getDrawable(R.drawable.c));

  }

  });

  imagebutton2.setOnClickListener(new OnClickListener(){

  @Override

  public void onClick(View v) {

  textview1.setText("點(diǎn)擊了第二個(gè)圖片按鈕");

  imagebutton2.setImageDrawable(getResources().getDrawable(R.drawable.d));

  imagebutton1.setImageDrawable(getResources().getDrawable(R.drawable.a));

  }

  });

  運(yùn)行程序,分別點(diǎn)擊ImageButton1和ImageButton2,可見如下效果:

  END

看了“android5.0程序開發(fā)的圖片按鈕ImageButton使用教程”的人還看了

1.android基礎(chǔ)教程視頻:Button圖文混排的按鈕

2.android中透明按鈕的設(shè)置教程

3.android基礎(chǔ)教程視頻:ToggleButton按鈕的使用

4.android基礎(chǔ)教程視頻:ImageView實(shí)現(xiàn)適屏和裁剪圖片

2076832 主站蜘蛛池模板: 午夜高清福利在线观看| 亚洲国产精品成人av网| 国产精品人成视频免| 国产成人影院一区二区三区| 亚洲av无码之国产精品网址蜜芽| 国产成人无码A区在线观看视频| 无码一区二区三区久久精品| 婷婷色香五月综合缴缴情香蕉| 国产成人精品国产成人亚洲| 97久久精品人人做人人爽| 亚洲成在人线av无码| 国产玩具酱一区二区三区| 亚洲一区二区三区自拍高清| 国产视频 视频一区二区| 草草浮力影院| 亚洲欧美人成人综合在线播放| 男人狂桶女人高潮嗷嗷| 国产av午夜精品福利| 国产精品一码二码三码| 黄色大全免费看国产精品| 国产95在线 | 欧美| 性欧美videofree高清精品| 91亚洲国产三上悠亚在线播放| 尤物视频色版在线观看| 日本中文一区二区三区亚洲| 秋霞人妻无码中文字幕| 四川丰满少妇无套内谢| av色国产色拍| 亚洲成人av一区免费看| 国内自拍视频一区二区三区| 综合区一区二区三区狠狠| 国产精品美女www爽爽爽视频 | 亚洲一区中文字幕人妻| 亚洲国产一成人久久精品| 人妻在线无码一区二区三区| 国产免费午夜福利在线播放| 久久精品国产只有精品96| 深夜精品免费在线观看| 九九视频热最新在线视频| 国产一级特黄高清大片一| 亚洲精品久久一区二区三区四区|