English 中文(简体)
Android 未决问题
原标题:Android XML Layout issue

我想就我第一次提出这样的问题作我的阐述:

enter image description here

I have already asked a question similar to this. I am getting stuck on the formatting: This is what my code looks like:

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

我的项目运行,但绝对没有在屏幕上显示任何情况? 非常感谢帮助!

Here is my activity class: 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);
}

    }
最佳回答

You need to properly define your layout, then you need to load your layout in the activity you are starting.

rel=“nofollow”http://developer.android.com/guide/topics/ui/declaring-layout.html

阁下

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

接着,你需要制造 Java,把你的XML装入 on法:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_layout);
}
问题回答

暂无回答




相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签