0

I have a tabView in android which is created as follows :

            Intent intentAndroid = new Intent().setClass(this, AndroidActivity.class);
        TabSpec tabSpecAndroid = tabHost.newTabSpec("Android");
        tabSpecAndroid.setIndicator("", ressources.getDrawable(R.drawable.icon_android_config));
        tabSpecAndroid.setContent(intentAndroid);

        // Apple tab
        Intent intentApple = new Intent().setClass(this, AppleActivity.class);
        TabSpec tabSpecApple = tabHost.newTabSpec("Apple");
        tabSpecApple.setIndicator("", ressources.getDrawable(R.drawable.icon_apple_config));
        tabSpecApple.setContent(intentApple); 

AppleActivity.class is as defined :

public class AppleActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.apple_layout);

        TextView textview = (TextView)findViewById(R.id.apple_textView);
        textview.setText("This is Apple tab");

    }
}

But I clicked in tab named "Apple" the String "This is Apple tab" in the TextView is not shown . What is wrong here ? Please help me with a solution . The picture is as follows :

enter image description here

But I when I clicked the others tab such as "Android" the picture is as follows :

enter image description here

Why the textView in android tab is working wee and why not in Apple tab ?

The alyout for AppleLayout.xml is as follows :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

    <ListView
      android:layout_height="wrap_content"
      android:layout_width="match_parent"
      android:id="@+id/listView1">
    </ListView>

    <TextView
      android:text="TextView"
      android:id="@+id/apple_textView"
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content">
    </TextView>

</LinearLayout>
4

1 に答える 1

0

android:orientation="vertical" を LinearLayout に追加します。デフォルトは水平に見えるため、テキストは右側にありますが、リストが親と一致するため表示されません。または、テキストビューをリストビューの上に置いて、表示されるかどうかを確認してください

于 2012-10-07T15:11:22.317 に答える