日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

html 添加窗口小部件,如何:为自定义窗口小部件定义主题(样式)项

發布時間:2024/7/23 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html 添加窗口小部件,如何:为自定义窗口小部件定义主题(样式)项 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

波斯汪

是的,有一種方法:假設您有一個小部件的屬性聲明(在中attrs.xml):? ? 聲明用于樣式參考的屬性(在中attrs.xml):? ? 為小部件聲明一組默認屬性值(在中styles.xml):聲明自定義主題(在中themes.xml):將此屬性用作窗口小部件的構造函數中的第三個參數(在中CustomImageButton.java):public class CustomImageButton extends ImageButton {? ? private String customAttr;? ? public CustomImageButton( Context context ) {? ? ? ? this( context, null );? ? }? ? public CustomImageButton( Context context, AttributeSet attrs ) {? ? ? ? this( context, attrs, R.attr.customImageButtonStyle );? ? }? ? public CustomImageButton( Context context, AttributeSet attrs,? ? ? ? ? ? int defStyle ) {? ? ? ? super( context, attrs, defStyle );? ? ? ? final TypedArray array = context.obtainStyledAttributes( attrs,? ? ? ? ? ? R.styleable.CustomImageButton, defStyle,? ? ? ? ? ? R.style.Widget_ImageButton_Custom ); // see below? ? ? ? this.customAttr =? ? ? ? ? ? array.getString( R.styleable.CustomImageButton_customAttr, "" );? ? ? ? array.recycle();? ? }}現在,您必須應用Theme.Custom到所有使用的活動CustomImageButton(在AndroidManifest.xml中):就這樣。現在CustomImageButton嘗試從customImageButtonStyle當前主題的屬性加載默認屬性值。如果在主題或屬性的值中未找到此類屬性@null,obtainStyledAttributes則將使用的最后一個參數:Widget.ImageButton.Custom在這種情況下。您可以更改所有實例和所有文件的名稱(除外AndroidManifest.xml),但是使用Android命名約定會更好。

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的html 添加窗口小部件,如何:为自定义窗口小部件定义主题(样式)项的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。