<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > Android設置選項開(kāi)發(fā)及自定義Preference樣式

Android設置選項開(kāi)發(fā)及自定義Preference樣式

作者: 時(shí)間:2016-09-12 來(lái)源:網(wǎng)絡(luò ) 收藏

2

本文引用地址:http://dyxdggzs.com/article/201609/304509.htm

3

4

5

6

7

復制代碼

2) 設計自定義Preference的布局 preferencewithtip.xml

1

2

3 android:layout_width=match_parent

4 android:layout_height=match_parent

5 android:orientation=horizontal

6 android:paddingLeft=8dp

7 android:paddingRight=15dp

8 android:paddingTop=20dp

9 android:paddingBottom=20dp>

10

11 android:id=@+id/prefs_title

12 android:layout_width=0dp

13 android:layout_height=wrap_content

14 android:layout_gravity=left

15 android:gravity=left|center_vertical

16 android:textSize=18sp

17 android:layout_weight=1/>

18

19 android:id=@+id/prefs_tip

20 android:layout_width=0dp

21 android:layout_height=wrap_content

22 android:layout_gravity=right

23 android:gravity=right|center_vertical

24 android:textSize=18sp

25 android:layout_weight=1/>

26

27

3) 繼承Preference,實(shí)現自己的Preference類(lèi) PreferenceWithTip

1 public class PreferenceWithTip extends Preference {

2 private static final String TAG = PreferenceWithTip;

3 String pTitle = null;

4 String tipstring = null;

5

6 @SuppressLint(Recycle)

7 public PreferenceWithTip(Context context, AttributeSet attrs, int defStyle) {

8 super(context, attrs, defStyle);

9 // 獲取自定義參數

10 Log.i(TAG,PreferenceWithTip invoked);

11 TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PreferenceWithTip);

12 tipstring = ta.getString(R.styleable.PreferenceWithTip_tipstring);

13 pTitle = ta.getString(R.styleable.PreferenceWithTip_titlestring);

14 ta.recycle();

15 }

16

17 public PreferenceWithTip(Context context, AttributeSet attrs) {

18 this(context, attrs, 0);

19 }

20

21 @Override

22 protected void onBindView(View view) {

23 super.onBindView(view);

24 TextView pTitleView = (TextView)view.findViewById(R.id.prefs_title);

25 pTitleView.setText(pTitle);

26 TextView pTipView = (TextView)view.findViewById(R.id.prefs_tip);

27 pTipView.setText(tipstring);

28 }

29

30 @Override

31 protected View onCreateView(ViewGroup parent) {

32 return LayoutInflater.from(getContext()).inflate(R.layout.preferencewithtip,

33 parent, false);

34 }

35

36 //如需更新、保存數據則需要繼續編寫(xiě)

37

38 }

4) 調用。調用代碼在文章的開(kāi)頭部分已經(jīng)貼出,主要代碼如下,preference是自定義的包名。

復制代碼

1

2 preference:tipstring=>

3 preference:titlestring=自定義測試 >

4

5 android:action=android.intent.action.VIEW

6 android:data=http://www.baidu.com />

7

復制代碼

總結一下Preference的使用還是比較簡(jiǎn)單的,自定義Preference也比較方便。但是要設計出一個(gè)漂亮的、人性化的Preference還是不那么容易,但這些都是提高用戶(hù)體驗的途徑,值得進(jìn)一步挖掘。


上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞:

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>