2017-03-22 1 views
0

laufen Ich habe Android Studio 2.2.2 undAndroid Studio, Tabs zeigen nicht, wenn ich das Projekt

ich ein einfaches Projekt mit einem TabHost und ein Textview „Hallo Welt“ zu erstellen, dann betreibe ich das Projekt mit USB concetion zu meinem Handy und wenn die App runnig ist sehe ich nicht die TabHost, Ich kann nur die "Hallo Welt" Textview .... die Registerkarte ist fehlt.

Das Projekt ist sehr einfach, nur um das Problem zu zeigen.

* Im Projekt res/layout/activity_main.xml Sie die TabHost sehen sehr gut

Vielen Dank im Voraus

Beispiel:

MainActivity.java

import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 

public class MainActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
    } 
} 

activity_main.xml (Relative-Layout)

Layout Preview

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Hello World!" 
    android:id="@+id/textView" /> 

<TabHost 
    android:layout_width="200dip" 
    android:layout_height="300dip" 
    android:layout_below="@+id/textView" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true"> 

    <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"> 

      <LinearLayout 
       android:id="@+id/tab1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/tab2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/tab3" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

      </LinearLayout> 
     </FrameLayout> 
    </LinearLayout> 
</TabHost> 
+0

Beitrag die Haupttätigkeit, welche Führer verweisen u, wenn Sie dies geschrieben hat? –

Antwort

0

MainActivity

th= (TabHost) findViewById(R.id.th); 
    th.setup(); 

    TabHost.TabSpec tab1=th.newTabSpec("Tab1"); 
    tab1.setIndicator("Page"); 
    tab1.setContent(R.id.tab1); 
    th.addTab(tab1); 

=/

Verwandte Themen