免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
android tabHost

我有2個關(guān)于tabHost的問題:
我用2個標(biāo)簽創(chuàng)建了tabHost
對于標(biāo)簽標(biāo)題,我使用setIndicator(TextView)
(我使用api 4級)
我的標(biāo)題背景是白色的.我使用選擇器作為標(biāo)題在標(biāo)題的差異圖像之間進(jìn)行選擇.

>我想僅在選擇/按下時使標(biāo)題文本變?yōu)榇煮w.我沒有成功使用我擁有的選擇器.我能做到嗎?我的想法是,在我使用drawable a的情況下,我想要文本粗體.其他案件不大膽.關(guān)于textColor的同樣問題.
>它看起來像一個錯誤 – 當(dāng)標(biāo)簽首次打開時,所選標(biāo)簽上的文本(我在tabHost.setCurrentTab(tabId)中使用的文本)根本看不到.在第一次按下/聚焦/聚焦任何其他項目后,它看起來很好.任何想法為什么或如何解決這個問題?

提前致謝

on tabActivity –

TextView title1 = new TextView(MainActivity.getInstnace(), null, android.graphics.Typeface.NORMAL);TextView title2 = new TextView(MainActivity.getInstnace(), null, android.graphics.Typeface.NORMAL);title1.setText("teb11 title");title1.setBackgroundResource(R.drawable.tabtitle);title1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.tab1), null, null, null);title2.setText("tab22 title");title2.setBackgroundResource(R.drawable.tabtitle);title2.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.tab2), null, null, null);TabSpec tab1 = mTabHost.newTabSpec("tab1").setIndicator(title1).setContent(R.id.list1);TabSpec tab2 = mTabHost.newTabSpec("tab2").setIndicator(title2).setContent(R.id.list2);mTabHost.addTab(tab1);mTabHost.addTab(tab2);      mTabHost.setCurrentTab(0);

選擇器tab1.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">      <item android:state_selected="true"         android:drawable="@drawable/iconselect"/>       <item android:state_pressed="true"      android:drawable="@drawable/iconselect"/>       <item android:drawable="@drawable/icon"/>        </selector> 

tabTitle的選擇器

<selector xmlns:android="http://schemas.android.com/apk/res/android">      <item android:state_pressed="true"      android:drawable="@drawable/tabselected"/>     <item android:state_selected="true"         android:drawable="@drawable/tab" />      <item android:state_focused="true"      android:drawable="@drawable/tab" />  </selector> 

解決方法:

對于你的問題#1:
在你的TabsAdapter上使用onPageSelected(int position),如下所示:

 public void onPageSelected(int position) {      //your logic here      fixTitleText(); }

和:

 private void fixTitleText() {      for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i  ) {           View view = mTabHost.getTabWidget().getChildAt(i);           TextView tv = (TextView) view.findViewById(android.R.id.title);           tv.setTextColor(getResources().getColor(R.drawable.text_selector));           tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);           tv.setTypeface(null, Typeface.BOLD);      } }

請注意,此代碼適用于HONEYCOMB及更高版本,在此之前,選項卡主機(jī)視圖層次結(jié)構(gòu)略有不同

來源:https://www.icode9.com/content-4-314351.html
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Android TabHost 標(biāo)簽放在底部+Header
【Android UI設(shè)計與開發(fā)】5.底部菜單欄(二)使用Fragment實現(xiàn)底部菜單欄
tabHost使用
Badge on Android TabHost
使用TabWidget實現(xiàn)Tab的切換
這點小技巧,可以節(jié)省50%開發(fā)時間,卻很容易被忽略
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服