Problem with tabs and focus

by khose » Wed, 22 Apr 2009 02:15:54 GMT


Sponsored Links
 Hello all.

I've got another little issue using tabs.

I've created a new TabHost handling 4 Tabs. Each tab has an Intent as
content. The first tab launches a new Activity that creates a new
Options Menu. When i change the tab and then come back to the first
one, that menu wont show at first. I have to put the focus into one
View inside in order to make the menu show again.

I've tried requesting focus inside the first Activity..

        @Override
        protected void onResume() {
                super.onResume();
                _searchText.setFocusable(true);
                _searchText.requestFocus();
        }

i've also tried this...

public class MainActivity extends TabActivity {
....
    @Override
    public void onCreate(Bundle savedInstanceState) {
....
        _tabhost = getTabHost();

        _tabhost.setDescendantFocusability
(ViewGroup.FOCUS_AFTER_DESCENDANTS);
}

But no luck at all... :S

Any Idea???

Thanks!
--~--~---------~--~----~------------~-------~--~----~



Problem with tabs and focus

by khose » Wed, 22 Apr 2009 19:31:12 GMT


 Any idea?? I've seen that everythig goes right when you define your
layout inside the tab container XML and you manage all the tabs within
the TabActivity. But its really confusing when you throw intents
instead. I also have some issues with the menu that each tab is
showing up....



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


Sponsored Links


Problem with tabs and focus

by Mark Murphy » Wed, 22 Apr 2009 19:42:49 GMT


 


Frankly, I have yet to see a good reason to use Intents to populate
tabs, particularly since you are limited to your own activities.

If this were my code, I would:

1. Move the UI logic for each of the activities to be put into tabs into
custom View classes rather than activity classes.

2. For those where I need the UI logic to appear both in a tab and in a
standalone activity, create a trivial activity wrapper around the view.

3. Use the custom View classes from step #1 in the TabActivity instead
of Intents.

4. Put the option menus in the TabActivity.

But, hey, that's just me.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Training:  http://commonsware.com/training.html 

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



Problem with tabs and focus

by khose » Wed, 22 Apr 2009 22:35:13 GMT


 Ok, understood. But i can't change now the way i manage those tabs. I
will consider your solution in future apps.
I think that the main reason to use Intents instead of views is that
some views can be hard to manage and the final TabActivity can be
really heavy to load and really ugly to read (the code i mean). So now
i need a "real" solution...

Thanks anyway Mark.





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



Problem with tabs and focus

by khose » Wed, 29 Apr 2009 02:32:58 GMT


 So, ive seen that the view inside that tab has focus. So it cant be a
focus problem. Its a strange behaviour bcos an edittext get the focus,
but its not orange-highlighted. I press down and up in the pad and
that edittext gets highlighted. If i press menu button after that,
then i can see the menu. (Its the only way to "force" it to appear...)

Thanks!







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



Other Threads

1. licensing cost for google maps?

Hi, I'm building a map component to a webview-based Android app. I
learned from the Google Sales department using the JavaScript API of
Google Maps has a licensing fee for Asset Tracking apps. But I can't
get an answer from them whether using the Android maps API also has a
licensing cost or it's free to use. Anyone knows it?

2. Ninja's Unboxing

lucu nih... sekaligus keren videonya
dan tentunya Nexus One nya juga :-)

http://www.youtube.com/watch?v=f_ETSvTAo4A

enjoy...

-vanda-

3. Data connectivity problem.Server failed to communicate

4. opencore compiling

5. Berapa account email..?

6. android gui is not coming up with yaffs2 filesystem

7. virtual keyboard on dialog webview not shown