日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
android TabHost解決下面白線

我之前做分頁都是用GridView和ActivityGroup實(shí)現(xiàn)的.因?yàn)橛X得TabHost不好用,還有就是自己水平差的原因吧.如果幫的話,重寫view任何問題都可以解決,呵呵,下面請(qǐng)看實(shí)現(xiàn)過程,其實(shí)很簡(jiǎn)單.      針對(duì)TabHost的運(yùn)用,我就不多講解了,網(wǎng)上例子好多,或者你也可以下載我的Demo查看,不過先聲明,寫的不好. 
      代碼片段:

成都創(chuàng)新互聯(lián)公司2013年開創(chuàng)至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元?dú)v下做網(wǎng)站,已為上家服務(wù),為歷下各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:028-86922220

?

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 public class MyActivity extends TabActivity {         private TabWidget tabWidget;           /** Called when the activity is first created. */         public void onCreate(Bundle savedInstanceState) {                 super.onCreate(savedInstanceState);                 setContentView(R.layout.main);                   Resources res = getResources(); // Resource object to get Drawables                 final TabHost tabHost = getTabHost(); // The activity TabHost                 TabHost.TabSpec spec; // Resusable TabSpec for each tab                 Intent intent; // Reusable Intent for each tab                   // Create an Intent to launch an Activity for the tab (to be reused)                 intent = new Intent().setClass(this, ArtistsActivity.class);                   // Initialize a TabSpec for each tab and add it to the TabHost                 spec = tabHost                                 .newTabSpec("artists")                                 .setIndicator("Artists",                                                 res.getDrawable(R.drawable.ic_tab_artists))                                 .setContent(intent);                 tabHost.addTab(spec);                   // Do the same for the other tabs                 intent = new Intent().setClass(this, AlbumsActivity.class);                 spec = tabHost                                 .newTabSpec("albums")                                 .setIndicator("Albums",                                                 res.getDrawable(R.drawable.ic_tab_artists))                                 .setContent(intent);                 tabHost.addTab(spec);                   intent = new Intent().setClass(this, SongsActivity.class);                 spec = tabHost                                 .newTabSpec("songs")                                 .setIndicator("Songs",                                                 res.getDrawable(R.drawable.ic_tab_artists))                                 .setContent(intent);                 tabHost.addTab(spec);                 tabHost.setCurrentTab(2);                 View v;                 tabWidget = tabHost.getTabWidget();                   for (int i = 0; i < tabWidget.getChildCount(); i++) {                         // 獲取tabview項(xiàng)                         v = tabWidget.getChildAt(i);                         // 設(shè)置tab背景顏色                         v.setBackgroundResource(Android.R.color.white);                         // 獲取textview控件,(默認(rèn)為白色)                         TextView textView = (TextView) v.findViewById(android.R.id.title);                         textView.setTextColor(Color.BLACK);                         // 默認(rèn)選項(xiàng)要處理                         if (tabHost.getCurrentTab() == i)                                 v.setBackgroundResource(R.drawable.renren_sdk_pay_repair_btn);                 }                 // tabchanged的監(jiān)聽                 tabHost.setOnTabChangedListener(new OnTabChangeListener() {                         // tabId顯示的是:newTabSpec里面的值                         @Override                         public void onTabChanged(String tabId) {                                 // 首先把所有的view背景初始化了.                                 for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {                                         View v = tabHost.getTabWidget().getChildAt(i);                                         // 設(shè)置tab背景顏色                                         v.setBackgroundResource(android.R.color.white);                                         // 選中的進(jìn)行處理                                         if (tabHost.getCurrentTab() == i) {                                                 v.setBackgroundResource(R.drawable.renren_sdk_pay_repair_btn);                                         }                                   }                         }                 });           } }

其實(shí)就是那幾行加注釋部分,相信你看一下就明白.

解決Tab下面白線方法:

首先我們要獲取Tab的分頁view和textview控件,因?yàn)閠extview默認(rèn)字體是白色.我們要進(jìn)行處理.獲取后進(jìn)行相應(yīng)處理(也就是該加背景的加背景,該改變字體顏色的改變字體顏色).***我們要對(duì)TabHost進(jìn)行監(jiān)聽(OnTabChangedListener);也不是什么監(jiān)聽,。就是用他的點(diǎn)擊執(zhí)行事件.


網(wǎng)站名稱:android TabHost解決下面白線
網(wǎng)頁URL:http://www.dlmjj.cn/article/djeieoi.html