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. License Verification Library: getting error NOT_MARKET_MANAGED

Hi!

I'm trying to integrate the LVL to my app, and I followed the
'Licensing Your Applications' document [1].

For some reason I'm receiving the ERROR_NOT_MARKET_MANAGED error,
although my app (package: org.jraf.android.logcatlivewallpaper) is
indeed available in the Market.

I suppose I made a mistake is on my side but all I did is follow the
document (I used the ServerManagedPolicy and the AESObfuscator), so I
don't see what I could have done wrong.

Any idea?
Thanks a lot for you help.

BoD

  [1]: http://developer.android.com/guide/publishing/licensing.html

-- 

2. what is the difference between notifyDataSetChanged() and notifyDataSetInvalidated() ?

Hi All,

I have a doubt that what is the difference between
adapter.notifyDataSetChanged();
adapter.notifyDataSetInvalidated();

because when i used both one by one, both worked exactly same.
Please let me know what is the exact difference between these two.

Thanks,
Sohan Badaya

-- 

3. Problem with reading contacts on Samsung Galaxy Europa

4. Get around the inability to alias columns coming from ContactsContract in 2.2

5. HTC EVO RTSP issues... Anyone experience issues in this area?

6. How can I get the EditText information from Inputmethod?

7. how to tether 3G mobile on android programmatically using Android SDK