• <output id="aynwq"><form id="aynwq"><code id="aynwq"></code></form></output>

    <mark id="aynwq"><option id="aynwq"></option></mark>
  • <mark id="aynwq"><option id="aynwq"></option></mark><label id="aynwq"><dl id="aynwq"></dl></label>
  • 學習啦>學習電腦>電腦技巧>

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

    時間: 本達868 分享

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

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

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

      將圖片素材導入到drawable目錄中,可以復制圖片文件,在drawable目錄中進行粘貼。注意圖片文件名不能以數字開頭,否則出錯。

      在activity_main.xml文件中加入一個TextView文本控件和兩個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文件,導入TextView控件類、ImageButton控件類聲明。

      import android.widget.TextView;

      import android.widget.ImageButton;

      在程序中加入文本控件和兩個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的執行代碼。點擊圖片按鈕會改變按鈕。

      imagebutton1.setOnClickListener(new OnClickListener(){

      @Override

      public void onClick(View v) {

      textview1.setText("點擊了第一個圖片按鈕");

      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("點擊了第二個圖片按鈕");

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

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

      }

      });

      運行程序,分別點擊ImageButton1和ImageButton2,可見如下效果:

      END

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

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

    2.android中透明按鈕的設置教程

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

    4.android基礎教程視頻:ImageView實現適屏和裁剪圖片

    2076832 主站蜘蛛池模板: 蜜桃成熟时2005| 91老师国产黑色丝袜在线| 精品人妻VA出轨中文字幕| 波多野结衣先锋影音| 国内精品久久久久| 亚洲va欧美va国产综合久久| 黄色一级免费网站| 无码免费一区二区三区免费播放| 动漫美女www网站免费看动漫| hdjapanhdsexxx| 欧美性猛交xxxx免费看蜜桃| 国产女人高潮视频在线观看| 中文字幕日本最新乱码视频| 男女下面一进一出无遮挡gif| 国产自产视频在线观看香蕉| 久久香蕉国产线看精品| 美女毛片一区二区三区四区| 天天爱天天做天天爽| 亚洲人成精品久久久久| 18禁裸乳无遮挡啪啪无码免费| 机机对在一起30分钟软件下载| 国产免费小视频在线观看| 一本大道香蕉在线影院| 欧美日韩免费大片| 国产亚洲人成无码网在线观看| …久久精品99久久香蕉国产 | 2022国产精品手机在线观看| 旧里番洗濯屋1一2集无删减 | 国产熟女乱子视频正在播放| 久久久久久久性| 狠狠综合久久久久尤物丿| 国产欧美亚洲专区第一页| 三级在线看中文字幕完整版| 欧美日韩国产成人高清视频| 国产乱叫456在线| 99在线在线视频免费视频观看| 日韩精品无码一区二区三区| 免费高清小黄站在线观看| www卡一卡二卡三| 尤物精品视频一区二区三区| 免费国产美女爽到喷出水来视频|