Access Listview from TabActivity

by Kid24 » Wed, 21 Apr 2010 02:30:27 GMT

Sponsored Links

I wonder if anyone can help me to solve my issue. The problem - I
can't find the way to get ListView reference that is the part of
I have 2 tabs - ListView, TextView. Theare no problem to access
TextView using the following code in TabActivity:

FrameLayout frame = tabHost.getTabContentView();
TextView text = (TextView)

But frame.getChildAt(0) returns$DecorView
And I actualy don't know the way how to cast this reference to the
object and to get its ListView child.

Could anybody help me, please?

Tab initialization code:

protected void onCreate(Bundle savedInstanceState) {

                final TabHost tabHost = getTabHost();

                                new Intent(this, MainListActivity.class)));

                                tabHost.getTabContentView(), true);



Access Listview from TabActivity

by Prajakta Shitole » Wed, 21 Apr 2010 05:26:56 GMT


You can have a list Activity and then in you tabActivity just pass that
activity in setcontent. For eg:
In the example below First.class and Second.class are my ListActivities.

public class ExampleTab extends TabActivity {

    protected void onCreate(Bundle savedInstanceState) {

        TabHost tabHost = getTabHost();


                .setContent(new Intent(this, First.class)));


                .setContent(new Intent(this, Second.class)));


Hope this helps,



Sponsored Links

Other Threads

1. Question for SDK developers - behavior of setFeatureInt

Good lord, DO NOT DO THIS.  Do you see what you are doing?  You are using
reflection to get at private information, and then using that information to
rip apart the system's decoration layout.  You WILL break in the future.  I
guarantee it.

Please, for me, slap whoever gave you this code.

And yes, this is how setFeatureInt() works.  It would be nice to have it be
more flexible, but for now you need to set these things up before
setContentView().  If you want a changing title bar, you'll need to set your
own custom title bar view up-front and just manage it all yourself.

Okay now I am going to go cry silently in the corner.

Dianne Hackborn
Android framework engineer

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.


2. Issue w/ extending MapActivity and eclipse error saying that it is not extended

So I am really confused, this has been going on for a while, usually I
could move my activity decleration around in the manifest and it would
work fine. Now its giving me the same error.

I have an activity called savemaplocation extending MapActivity
public class savemaplocation extends MapActivity

I have this line in my manifest for this particular activity
       <activity class=".savemaplocation"
android:label="SaveMapLocation" android:name=".savemaplocation"

it keeps saying as an error next to the line in the
manifest .....savemaplocation does not extend

I am kind of confused, my other activity that happens to be a
MapActivity has no issues.. Help would really be appreciated.


3. build-essential on Mandriva virtual machine

4. ALSA proble

5. Reading /proc and /sy

6. PV2wayEngine crash

7. why XmlPullParser.getName(); return null (urgent)