Android窗口小部件基礎(chǔ)編寫代碼實(shí)例
實(shí)現(xiàn)窗口小部件,訪問(wèn)手機(jī)儲(chǔ)存卡指定目錄中的圖片文件,然后隨機(jī)選擇一張?jiān)诖翱诘男〔考酗@示。圖片路徑使用List存儲(chǔ),適合初級(jí)Android學(xué)習(xí)者參考。本系統(tǒng)無(wú)服務(wù),不能保證進(jìn)程長(zhǎng)存。
新建一個(gè)空的布局項(xiàng)目,然后新建一個(gè)Widget,如圖所示:
在新建的xml和java實(shí)現(xiàn)類中進(jìn)行編寫即可。
picture_widget.xml文件如下:
<RelativeLayout xmlns:android='http://schemas.android.com/apk/res/android' android:layout_width='match_parent' android:layout_height='match_parent' android:padding='@dimen/widget_margin'> <ImageView android: android:layout_width='match_parent' android:layout_height='match_parent' android:src='http://www.4tl426be.cn/bcjs/@drawable/zhizhuxia' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:text='' android:textSize='10dp' android:gravity='right|bottom' android:layout_marginRight='2dp' android:layout_marginBottom='2dp'/></RelativeLayout>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. moment轉(zhuǎn)化時(shí)間戳出現(xiàn)Invalid Date的問(wèn)題及解決2. python爬蟲實(shí)戰(zhàn)之制作屬于自己的一個(gè)IP代理模塊3. 使用JSP技術(shù)實(shí)現(xiàn)一個(gè)簡(jiǎn)單的在線測(cè)試系統(tǒng)的實(shí)例詳解4. asp批量添加修改刪除操作示例代碼5. 開(kāi)發(fā)效率翻倍的Web API使用技巧6. HTML 絕對(duì)路徑與相對(duì)路徑概念詳細(xì)7. 解決ajax請(qǐng)求后臺(tái),有時(shí)收不到返回值的問(wèn)題8. ajax請(qǐng)求后臺(tái)得到j(luò)son數(shù)據(jù)后動(dòng)態(tài)生成樹形下拉框的方法9. .NET6打包部署到Windows Service的全過(guò)程10. WML的簡(jiǎn)單例子及編輯、測(cè)試方法第1/2頁(yè)
