Access Listview from TabActivity

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


Sponsored Links
 Hello,

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
TabActivity.
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)
((LinearLayout)frame.getChildAt(1)).getChildAt(0);

But frame.getChildAt(0) returns
com.android.internal.policy.impl.PhoneWindow$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) {
                super.onCreate(savedInstanceState);

                final TabHost tabHost = getTabHost();

                tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator(
                                getString(R.string.tab_auth_list)).setContent(
                                new Intent(this, MainListActivity.class)));

                LayoutInflater.from(this).inflate(R.layout.help,
                                tabHost.getTabContentView(), true);

                tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator(
                                
getString(R.string.tab_help)).setContent(R.id.help_txt));
}

--



Access Listview from TabActivity

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


 Hi,

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 {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabst);

        TabHost tabHost = getTabHost();

        tabHost.addTab(tabHost.newTabSpec("tab1")

 .setIndicator("First",getResources().getDrawable(R.drawable.tab1))
                .setContent(new Intent(this, First.class)));

        tabHost.addTab(tabHost.newTabSpec("tab2")

 .setIndicator("Second",getResources().getDrawable(R.drawable.second))
                .setContent(new Intent(this, Second.class)));


    }
}


Hope this helps,

Thanks,
Prajakta






>


Sponsored Links


Other Threads

1. Andoird SDK 2.0

Hi,


How to download Andoird SDK 2.0 file...
I need Andoird SDK 2.0 like 1.5...
I tryed to download that.
But it downloaded only 2.0 file updates.
we want to update it from 1.5 or 1.6...

Any one know how to donwload 2.0
pls reply to me....


-- 
Thanks & Regards
Sasikumar.S

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

2. Reg the shared user id between application

Hi,

  I just started with Android.I came across this concept "two
applications to share the same user ID, in which case they will be
able to see each other's files".Have got some silly doubts reg this.
What exaclty does this mean?My basic doubt is if two applications can
share the data's,and that these two application can also co-exist at a
single point of time (say both the app is running), Then how is the
data protected?
Whats is the exact purpose of having two application to share the user-
id?

please help me in understanding this concept.

Regards,
Raji

-- 

3. Importing existing source into NetBeans

4. top ListActivity destroyed just after a Search has been initiated from it - was: Back key after Search doesn't return to list in 2.0 as it did in all earlier versions

5. sending mock location data to emulator?

6. Have you ever has a experience with JSP

7. How to use external library in Android project