乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      android tabHost

       印度阿三17 2019-07-10

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

      >我想僅在選擇/按下時使標題文本變?yōu)榇煮w.我沒有成功使用我擁有的選擇器.我能做到嗎?我的想法是,在我使用drawable a的情況下,我想要文本粗體.其他案件不大膽.關于textColor的同樣問題.
      >它看起來像一個錯誤 – 當標簽首次打開時,所選標簽上的文本(我在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./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./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及更高版本,在此之前,選項卡主機視圖層次結構略有不同

      來源:https://www./content-4-314351.html

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約