2013-06-13 4 views
9

में टैब टेक्स्ट को कैसे बदला जाए, मुझे प्रोग्राम को बदलने के तरीके पर समाधान पता है, हालांकि मैं एक्सएमएल में टेक्स्ट सेट करना चाहता हूं। आप उसे कैसे करते हैं? मैंने यहां देखा है: http://developer.android.com/reference/android/widget/TabHost.html लेकिन कोई समाधान नहीं मिला।टैबहोस्ट - एक्सएमएल

+0

क्या यह वास्तव में काम करता था? मुझे दूसरों के समान समस्या मिल रही है। क्या आपको इसके लिए अतिरिक्त जावा कोड करना है? –

उत्तर

9

के बारे में ....

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"> 

       <TextView 
        android:tag="tab0" 
        android:text="Tab 1" 
        android:background="@android:drawable/btn_star_big_on" 
        android:layout_width="wrap_content" 
        android:layout_height="fill_parent" 
        /> 
       <TextView 
        android:tag="tab1" 
        android:text="Tab 2" 
        android:layout_width="wrap_content" 
        android:layout_height="fill_parent" 
        /> 
       <TextView 
        android:tag="tab2" 
        android:text="Tab 3" 
        android:layout_width="wrap_content" 
        android:layout_height="fill_parent" 
        /> 

      </TabWidget> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 

       <TextView 
        android:text="Hallo1" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" /> 
       <TextView 
        android:text="Hallo2" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" /> 
       <TextView 
        android:text="Hallo3" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" /> 

      </FrameLayout> 
     </LinearLayout> 
    </TabHost> 

</RelativeLayout> 

इस तरह के रूप में ध्यान देंगे इस प्रकार कैसे:

TabHost

चेक बाहर पूरा टैब नमूना here

उम्मीद है कि यह मदद करता है .... चीयर्स!

+1

यह मेरे लिए काम नहीं करता ... – Supuhstar

+0

@ सुपुहस्टार: क्या आप समझा सकते हैं कि आपको क्यों या क्या त्रुटि मिली? – Trinimon

+5

कोई त्रुटि नहीं, बस ... बिल्कुल इस में से कोई भी काम नहीं किया। 'टेक्स्ट व्यू पूर्वावलोकन में टैब के बाईं ओर दिखाई देता है, और वास्तविक डिवाइस पर चलने पर कोई टैब दिखाई नहीं देता है। कोई कार्यक्षमता प्राप्त नहीं होती है और टुकड़े एक दूसरे के ऊपर दिखाई देते हैं – Supuhstar

1

आप हमेशा @ + id/tab1 में जा सकते हैं और जिसे आप टैब को कॉल करना चाहते हैं उसे बदल सकते हैं। तो यदि आप चाहते थे कि इसे "इसके बारे में" कहा जाए तो इसे विशिष्ट टैब के लिए रैखिक लेआउट में @ + id/about में बदलें।

+0

प्रश्न एक्सएमएल के बारे में है। क्या सूत्र आप xpath क्वेरी देते हैं? यदि ऐसा है, तो कृपया एक उदाहरण दें, हर कोई स्पष्ट रूप से xpath नहीं पढ़ सकता है। –

+2

i18n के बारे में क्या? – gattsbr

+0

इस पर बहुत देर हो चुकी है, लेकिन जोर्जेंसन टैब आईडी के बारे में बात कर रहा था, डिफ़ॉल्ट रूप से, टैबहोस्ट आईडी के टैब लेबल के रूप में उपयोग करता है। लेकिन जैसा कि @ गैट्सब्र ने बताया, यह समाधान केवल प्रयोग योग्य है यदि आप स्ट्रिंग अनुवाद फ़ाइलों का उपयोग नहीं करते हैं – STremblay

संबंधित मुद्दे