Android窗口小部件基礎(chǔ)編寫代碼實(shí)例
實(shí)現(xià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.piao2010.com/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. CSS hack用法案例詳解2. JSP servlet實(shí)現(xiàn)文件上傳下載和刪除3. ASP.NET Core實(shí)現(xiàn)中間件的幾種方式4. Jsp+Servlet實(shí)現(xiàn)文件上傳下載 刪除上傳文件(三)5. 詳解瀏覽器的緩存機(jī)制6. 怎樣才能用js生成xmldom對(duì)象,并且在firefox中也實(shí)現(xiàn)xml數(shù)據(jù)島?7. input submit、button和回車鍵提交數(shù)據(jù)詳解8. 怎樣打開XML文件?xml文件如何打開?9. 詳解盒子端CSS動(dòng)畫性能提升10. css代碼優(yōu)化的12個(gè)技巧
