成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

android TabHost解決下面白線

移動開發 Android
我之前做分頁都是用GridView和ActivityGroup實現的.因為覺得TabHost不好用,還有就是自己水平差的原因吧.如果幫的話,重寫view任何問題都可以解決

我之前做分頁都是用GridView和ActivityGroup實現的.因為覺得TabHost不好用,還有就是自己水平差的原因吧.如果幫的話,重寫view任何問題都可以解決,呵呵,下面請看實現過程,其實很簡單.      針對TabHost的運用,我就不多講解了,網上例子好多,或者你也可以下載我的Demo查看,不過先聲明,寫的不好. 
      代碼片段:

 

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項
                        v = tabWidget.getChildAt(i);
                        // 設置tab背景顏色
                        v.setBackgroundResource(android.R.color.white);
                        // 獲取textview控件,(默認為白色)
                        TextView textView = (TextView) v.findViewById(android.R.id.title);
                        textView.setTextColor(Color.BLACK);
                        // 默認選項要處理
                        if (tabHost.getCurrentTab() == i)
                                v.setBackgroundResource(R.drawable.renren_sdk_pay_repair_btn);
                }
                // tabchanged的監聽
                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);
                                        // 設置tab背景顏色
                                        v.setBackgroundResource(android.R.color.white);
                                        // 選中的進行處理
                                        if (tabHost.getCurrentTab() == i) {
                                                v.setBackgroundResource(R.drawable.renren_sdk_pay_repair_btn);
                                        }
 
                                }
                        }
                });
 
        }
}



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

解決Tab下面白線方法:

首先我們要獲取Tab的分頁view和textview控件,因為textview默認字體是白色.我們要進行處理.獲取后進行相應處理(也就是該加背景的加背景,該改變字體顏色的改變字體顏色).***我們要對TabHost進行監聽(OnTabChangedListener);也不是什么監聽,。就是用他的點擊執行事件.

責任編輯:冰凝兒 來源: android TabHost解決下面白線
相關推薦

2010-03-26 14:43:09

CentOS系統

2017-03-30 20:45:26

2011-03-11 12:27:16

康普思科

2012-04-17 14:30:28

2023-04-28 14:58:10

Python地圖循環點

2015-05-12 15:43:32

2011-04-21 11:21:47

Linux路徑

2013-01-29 10:07:08

綜合布線數據機柜

2011-06-08 16:22:24

白盒測試

2012-04-13 19:15:56

HTC

2014-11-26 09:59:36

PMC

2015-02-02 16:32:16

別踩白塊游戲OGEngine

2022-09-19 00:34:32

滲透測試安全漏洞

2010-01-27 16:30:47

Android選項卡

2019-02-18 11:50:49

技術黑客網絡安全

2013-04-03 12:57:01

Android開發讀寫assets目錄下

2023-12-21 15:18:29

2011-10-31 13:37:11

華為云計算

2009-12-22 15:58:08

2011-04-27 09:51:23

投影機
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 99re热这里只有精品视频 | 一级黄色片免费在线观看 | 91人人看| 91福利在线导航 | 欧美精品一区二区三区在线播放 | 久久久久国产一区二区三区四区 | 狠狠狠色丁香婷婷综合久久五月 | 国产一级一级毛片 | 国产欧美一级二级三级在线视频 | 精品国产欧美 | 色花av| 中文一区二区 | 国产精品视频二区三区 | 亚洲狠狠爱 | 国产黄色在线观看 | 久久久免费电影 | 亚洲视频在线看 | 免费精品| 在线免费观看黄色av | 久久99久久 | 激情伊人网 | 五月天激情综合网 | 中文字幕亚洲精品 | 欧美激情一区二区三级高清视频 | 97视频在线观看网站 | 欧美精品在线看 | 中文一级片| 亚洲欧美男人天堂 | 亚洲人久久 | 欧美午夜一区 | 中文字幕成人av | 日韩不卡视频在线观看 | 日本高清精品 | 天天天天天操 | 成人国产精品久久久 | 欧美一级黑人aaaaaaa做受 | 国产精品夜夜春夜夜爽久久电影 | av入口| 精品国产一区探花在线观看 | 亚洲欧美综合精品久久成人 | 国产一区二区麻豆 |