2013-02-03 7 views
5

मुझे "टैब संकेतक बनाने के लिए एक तरीका निर्दिष्ट करना होगा" त्रुटि (लॉगकैट के अनुसार)। कारण नहीं मिला।कारण नहीं मिला "आपको टैब संकेतक बनाने के लिए एक तरीका निर्दिष्ट करना होगा"

मुख्य वर्ग:

package org.tatvamoksh.tml; 


import android.app.TabActivity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.Window; 
import android.widget.TabHost; 
import android.widget.TabHost.TabSpec; 

@SuppressWarnings({ "deprecation" }) 
public class MainActivity extends TabActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    //Remove title bar 
    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

    setContentView(R.layout.activity_main); 

    TabHost tabHost = getTabHost(); 

    // Tab for Tatva 
    TabSpec t = tabHost.newTabSpec("Tatva"); 
    // setting Title and Icon for the Tab 
    t.setIndicator("Tatva"); 
    Intent tatvaIntent = new Intent(this, TatvaActivity.class); 
    t.setContent(tatvaIntent); 

    // Tab for Moksh 
    TabSpec m = tabHost.newTabSpec("Moksh"); 
    m.setIndicator("Moksh"); 
    Intent mokshIntent = new Intent(this, MokshActivity.class); 
    m.setContent(mokshIntent); 

    //Tab for Updates 
    TabSpec u = tabHost.newTabSpec("Updates"); 
    m.setIndicator("Updates"); 
    Intent updatesIntent = new Intent(this, Updates.class); 
    m.setContent(updatesIntent); 

    // Adding all TabSpec to TabHost 
    tabHost.addTab(t); // Adding Tatva tab 
    tabHost.addTab(m); // Adding Moksh tab 
    tabHost.addTab(u); // Adding Updates tab 
} 
} 

लेआउट फ़ाइल:

<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" 
tools:context=".MainActivity" > 

<TabHost 
android:id="@android:id/tabhost" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" > 

    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

     <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

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

      <ListView 
      android:id="@android:id/list" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 
      </ListView> 
     </FrameLayout> 
    </LinearLayout> 
</TabHost> 
</RelativeLayout> 

निम्नलिखित कोड बाहर टिप्पणी करते हुए यह ठीक करता है।

 //Tab for Updates 
    TabSpec u = tabHost.newTabSpec("Updates"); 
    m.setIndicator("Updates"); 
    Intent updatesIntent = new Intent(this, Updates.class); 
    m.setContent(updatesIntent); 

मुझे सही समस्या का अनुमान नहीं लगाया जा सकता है। किसी भी मार्गदर्शन के लिए आभारी होंगे।

उत्तर

7

परिवर्तन अंतिम टैब कोड के रूप में:

//Tab for Updates 
    TabSpec u = tabHost.newTabSpec("Updates"); 
    u.setIndicator("Updates"); 
    Intent updatesIntent = new Intent(this, Updates.class); 
    u.setContent(updatesIntent); 

क्योंकि आप TabSpec u के लिए संकेतक और सामग्री की स्थापना नहीं कर रहे हैं (आप मीटर टैब के लिए सेट कर रहे हैं)

+0

आह ... कैसे मुझे लगता है कि याद आती है हो सकता है। बहुत बहुत धन्यवाद :) – hypd09

+0

@spexy: सबसे स्वागत है दोस्त –

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