Getting different views in Tabs

by tysmailbox » Thu, 31 Dec 2009 05:09:48 GMT


Sponsored Links
 I have an app with 2 tabs, the first is a listview, and the second I'm
trying to make a TextView. The problem is I have no idea on how to get
the TextView to show up. The listview is working, but I can't get
anything on the TextView at all. I tried using the Hello, World to try
to work with the text into the tab, but I can't figure it out.

My main.xml section with the TabWidget looks like this:
-----------------------------

    <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">
            <ListView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/itemlist" />
            <TextView
                android:id="@+id/HelloAndroid"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"/>
        </FrameLayout>

-----------------------------
ListView is being used on the java file with the mTabHost code,
-----------------------------

        TabHost mTabHost = getTabHost();

    mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator
("Answer").setContent(R.id.itemlist));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator
("Ask").setContent(R.id.HelloAndroid));

    mTabHost.setCurrentTab(0);
}
-----------------------------

The TextView is on a different file called HelloAndroid.java, and the
code looks like:
-----------------------------

public class HelloAndroid extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
   }
}
-----------------------------

How can I fix it so that the 2nd tab brings up the example text?
Thanks!

--



Getting different views in Tabs

by tysmailbox » Fri, 01 Jan 2010 09:09:35 GMT


 Nevermind I got help from someone by adding
---
Intent i = new Intent(this, HelloAndroid.class);
 mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator
("Ask").setContent(i));
---
in place of the second mTabHost




--


Sponsored Links


Other Threads

1. DEVELOPER CHALLENGE 2 - Can update of existing published app can participate?

Hi

I know that currenlty published apps can't participate and also
updates of the apps which participated in Developer Challenge 1 cant
participate in DC2.

But can an update of an existing published app can participate in DC2?

Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~

2. How could I customize the launcher without modify the SDK?

Sorry, no, the user needs to do that.












-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~

3. Can android run java class files

4. Problem with Displaying Web Server's Response (Text) in Android

5. Installing the USB driver for HTC Magic on Vista

6. Live at Michael Jackson Memorial Concert -- All Videos here???

7. Can't install usb driver because Windows do not pop "New hardware wizard"