最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android中的Button自定義點擊效果實例代碼

 更新時間:2013年05月29日 10:58:39   作者:  
Android中的Button自定義點擊效果實例代碼,需要的朋友可以參考一下

方法一
1.放在drawable下的selector.xml文件

復(fù)制代碼 代碼如下:

<android="http://schemas.android.com/apk/res/Android">

   android:drawable="@drawable/temp2" />

2.布局文件main.xml

復(fù)制代碼 代碼如下:

<http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
 <android:drawableTop="@drawable/shouru"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/button"
 android:background="@drawable/selector"/>

 方法二
1.布局文件main.xml
[code]
<http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
 <android:id="@+id/button"
 android:drawableTop="@drawable/shouru"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/button"
 android:background="@drawable/temp4"/>


2.主要的java代碼,實現(xiàn)點擊效果:
復(fù)制代碼 代碼如下:

   Button button = (Button) this.findViewById(R.id.button);
   button.setOnTouchListener(new Button.OnTouchListener(){
   @Override
   public boolean onTouch(View v, MotionEvent event) {
    if(event.getAction() == MotionEvent.ACTION_DOWN){  
                    v.setBackgroundResource(R.drawable.temp1);  
                    Log.i("TestAndroid Button", "MotionEvent.ACTION_DOWN");
                }  
                else if(event.getAction() == MotionEvent.ACTION_UP){  
                    v.setBackgroundResource(R.drawable.temp2);
                    Log.i("TestAndroid Button", "MotionEvent.ACTION_UP");
                }
    return false;
   }
  });

相關(guān)文章

最新評論

临高县| 汨罗市| 肇庆市| 修水县| 二手房| 林芝县| 铁岭市| 旌德县| 红安县| 富顺县| 什邡市| 嘉黎县| 临高县| 稻城县| 荣昌县| 宜章县| 苍山县| 霍城县| 禄丰县| 湛江市| 上思县| 无锡市| 旬邑县| 青河县| 太湖县| 四平市| 秭归县| 呼伦贝尔市| 衡山县| 托克逊县| 峨边| 泰安市| 河津市| 花垣县| 营山县| 鹤壁市| 麦盖提县| 海宁市| 广水市| 永靖县| 霍州市|