2011-07-19 13 views
0

のAndroid XMLレイアウトの問題

enter image description here

私はすでにこれに似た質問をしてきました。私は、フォーマット上で立ち往生しています: これは私のコードは次のようになります。

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    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"   
      android:padding="5dp">   
     <TabWidget 
      android:id="@android:id/tabs"    
      android:layout_width="fill_parent"    
      android:layout_height="wrap_content" />   
     <FrameLayout    
      android:id="@android:id/tabcontent"    
      android:layout_width="fill_parent"    
      android:layout_height="fill_parent"    
      android:padding="5dp" /> 
      <RelativeLayout 
       android:orientation="vertical"     
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" >    
       <ImageView 
        android:id="@+id/simpleMode" 
        android:layout_width="wrap_content"   
        android:layout_height="wrap_content" 
        android:padding = "5dip" 
        android:layout_alignParentLeft="true"   
        android:src="@drawable/ic_tab_artists_grey" /> 
       <TextView  
        android:id="@+id/right_text"   
        android:layout_width="fill_parent"   
        android:layout_height="wrap_content"   
        android:padding="5dip"   
        android:layout_toRightOf="@+id/simpleMode"   
        android:gravity="right"    
        android:text="Description"  />     
      </RelativeLayout>  
     </LinearLayout> 
</TabHost> 

マイプロジェクトが実行されますが、絶対に何も画面に現れていませんか?ヘルプは非常に感謝!

ここは私のアクティビティクラスです: package com.joshi.remotedoc;

import android.app.TabActivity; 
import android.os.Bundle; 
import android.widget.TabHost; 
import android.content.Intent; 
import android.content.res.Resources; 

public class Detailed_ModeActivity extends TabActivity { 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.patientmode);  
     Resources res = getResources(); 
     // Resource object to get Drawables  
     TabHost tabHost = getTabHost(); 
     // The activity TabHost  
     TabHost.TabSpec spec; 
     // Reusable TabSpec for each tab 
     Intent intent; 
     // Reusable Intent for each tab 
     // Create an Intent to launch an Activity for the tab (to be reused) 
     intent = new Intent().setClass(this, SimpleMode.class); 
     // Initialize a TabSpec for each tab and add it to the TabHost 
     spec = tabHost.newTabSpec("simpleMode").setIndicator("simpleMode", 
       res.getDrawable(R.drawable.ic_tab_artists_white)) 
       .setContent(intent);  
     tabHost.addTab(spec); 
     // Do the same for the other tabs 
     intent = new Intent().setClass(this, DetailedMode.class); 
     spec = tabHost.newTabSpec("2ndtab").setIndicator("MySecondTab",       res.getDrawable(R.drawable.something))      .setContent(intent); 
     // Initialize a TabSpec for each tab and add it to the TabHost 
     spec = tabHost.newTabSpec("detailedMode").setIndicator("detailedMode", 
       res.getDrawable(R.drawable.ic_tab_artists_grey)) 
       .setContent(intent);  
     tabHost.addTab(spec); 
     tabHost.setCurrentTab(2); 
} 

    } 

答えて

1

レイアウトを適切に定義する必要があります。次に、開始するアクティビティでレイアウトを読み込む必要があります。

http://developer.android.com/guide/topics/ui/declaring-layout.html

まず、あなたのXML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical" > 
    <TextView android:id="@+id/text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Hello, I am a TextView" /> 
    <Button android:id="@+id/button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Hello, I am a Button" /> 
</LinearLayout> 

を作成次に、OnCreateの方法であなたのXMLをロードするためのJavaを作成する必要があります。

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main_layout); 
} 
+0

私はすでにこの – YoKaGe

+0

ルックを行っています編集したバージョンで – YoKaGe

+0

画面は空白ですか? –

関連する問題