Android Button的基本用法詳解及簡(jiǎn)單實(shí)例
Android Button的基本用法詳解
Button的Click點(diǎn)擊事件處理:
mButtonBack.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Log.e("================", "MenuBackBtnListen"); MenuimageView.setVisibility(View.INVISIBLE); mButtonBack.setVisibility(View.INVISIBLE); buttonCmdLl.setVisibility(View.INVISIBLE); mLabel.setVisibility(View.INVISIBLE); } });
Button的Press狀態(tài)的獲取及調(diào)用:
mButtonBack.setOnTouchListener(new View.OnTouchListener() { InputStream is = null; @Override public boolean onTouch(View arg0, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN){ try { is = asm.open("ReturnBtnPress.png"); } catch (IOException e) { e.printStackTrace(); } }else if(event.getAction() == MotionEvent.ACTION_UP){ try { is = asm.open("ReturnBtnNormal.png"); } catch (IOException e) { e.printStackTrace(); } } mButtonBack.setBackground(Drawable.createFromStream(is, null)); return false; } });
說明:
private AssetManager asm; asm=getAssets();
圖片資源是放在 /Android/assets/ 文件夾下。
沒有用R資源引用圖片。
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- Android定制RadioButton樣式三種實(shí)現(xiàn)方法
- Android控件之ToggleButton的使用方法
- Android控件系列之RadioButton與RadioGroup使用方法
- Android RadioButton單選框的使用方法
- Android點(diǎn)擊Button實(shí)現(xiàn)功能的幾種方法總結(jié)
- Android中button實(shí)現(xiàn)onclicklistener事件的兩種方式
- Android 控件(button)對(duì)齊方法實(shí)現(xiàn)詳解
- android RadioButton和CheckBox組件的使用方法
- Android控件系列之Button以及Android監(jiān)聽器使用介紹
相關(guān)文章
詳解RxJava2 Retrofit2 網(wǎng)絡(luò)框架簡(jiǎn)潔輕便封裝
本篇文章主要介紹了詳解RxJava2 Retrofit2 網(wǎng)絡(luò)框架簡(jiǎn)潔輕便封裝,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-12-12Android實(shí)現(xiàn)簡(jiǎn)單畫中畫功能
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡(jiǎn)單畫中畫功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08簡(jiǎn)單實(shí)現(xiàn)Android刮刮卡效果
這篇文章主要教大家如何簡(jiǎn)單的實(shí)現(xiàn)Android刮刮卡效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07Android用RecyclerView實(shí)現(xiàn)動(dòng)態(tài)添加本地圖片
本篇文章主要介紹了Android用RecyclerView實(shí)現(xiàn)動(dòng)態(tài)添加本地圖片,具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08Android實(shí)現(xiàn)列表數(shù)據(jù)按名稱排序、中英文混合排序
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)列表數(shù)據(jù)按名稱排序、中英文混合排序,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-09-09Android實(shí)現(xiàn)可折疊式標(biāo)題欄
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)可折疊式標(biāo)題欄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-09-09Android中使用orc實(shí)現(xiàn)文字識(shí)別實(shí)例
這篇文章主要介紹了Android中使用orc實(shí)現(xiàn)文字識(shí)別實(shí)例,詳細(xì)的介紹了orc的簡(jiǎn)介和用法,有興趣的可以了解一下2017-05-05