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. New DroidDraw Release...

Hey Folks,
After two months (and nearly 6000 downloads!)
There is a new release of DroidDraw available, including executables
for Mac OS X, Windows and Linux.

For those just tuning in, DroidDraw is a Drag 'n Drop UI designer for
creating layout XML files.

See:

http://www.droiddraw.org
http://code.google.com/p/droiddraw/

Highlights of this release:
* Initial Support for User Preferences
* Scrollview now draws correctly
* Support for the layout_margin* family of properties
* Misc. bug fixes.

For complete details and witty anecdotes of development see my
development blog:

http://droiddraw.blogspot.com

btw, congrats to all of the contest entrants, and especially the 50
finalists.  If you used DroidDraw for your app. I'd love to hear about
it...

bugs/feature requests/candy/caffeine -> brendan.d.burns on gmail.
--brendan
--~--~---------~--~----~------------~-------~--~----~

2. PLZ SEND A COMPLETE CODE OF VIDEO PLAYING

HI
i want to play the video in android.
plz send a code.
thanks in advance
--~--~---------~--~----~------------~-------~--~----~

3. want to take the height and width of editText from String file

4. want to take the height and width of editText from String file

5. "Menu" button disabled when I override onKeyDown

6. Null pointer Exception while accessing Textfile

7. "Menu" button disabled when I override onKeyDown