Office Hours — Today, April 11

Thursday, April 7

Apr 11
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
Dimitri
has entered the room
Dimitri
Hello Mark,
Mark M.
howdy, Dimitri
10:00 AM
Mark M.
how can I help you today?
10:00 AM
Dimitri
I have a question regarding implementation of Viewflipper and Tabhosts.
Can i upload an image i think be quicker to describe what i want exactly...?
Mark M.
sure
try the "Upload a file" link on the right
Dimitri
I am developing a application for ferry schedules in greece...
What i would like to do is be able to flip between two sets of tabs ... depicting Oneway and Return journeys...
So basicaly flip the whole image to show the return trips...
Mark M.
that's going to be one fat activity
one ViewFlipper holding two TabHosts holding a total of 14...ListViews?
Dimitri
Exactly which is really getting to complicated for my liking...
10:05 AM
Mark M.
the dates are the same for both sets, right?
Dimitri
nope... the return date might be later...
Mark M.
ah, right
Dimitri
i.e leaves on 05/04 returns on 23/04 has a spam of a week each time
Mark M.
I wish TabHost were more flexible
there's no clean way to change tab indicators once the tabs are created
very frustrating
so, you will probably wind up with two TabHosts anyway
the only question is: is this one activity with a ViewFlipper, or two instances of the "view possible itineraries" activity?
I'd consider going with the latter
Dimitri
this is part of my questuin
Sorry i did not get that, so how would my layout.xml be?
10:10 AM
Mark M.
the activity you show above could be used for either departures or returns
they have the same structure
Dimitri
Yes.
Mark M.
for the purposes of discussion, what's the name of this activity?
Dimitri
TripResults
Mark M.
OK
So, you would have one TripResults activity showing the departures
somewhere (e.g., action bar, options menu), you would have an option to view returns
that would start up another TripResults that views the returns
Dimitri
ah... i see a new activity i was trying to do all in one and kept on getting null pointer...
one more question when i am loading the tabs... as indicated in the image the users input 5/04 is the centered tab...
10:15 AM
Dimitri
What happens however although i set host.setCurrentTabByTag(...) the activity will load the initials tabs data as well?
Is there a way to avoid this...
Mark M.
I do not see where setCurrentTabByTag() would cause this
it probably loads all the tabs when you add them
I am guessing, based on your phrasing, that you are using activities as the contents of the tabs?
Dimitri
In order to fill each tab of the TripResults activity i am using a TripActivity extending ListActivity to fill the resulting trips..
Yes its the same activity for each tab..
10:20 AM
Mark M.
yeah, I don't use activities-in-tabs very much
adds overhead for no value, IMHO
Dimitri
Granted i am very new to android this might not be the best approach, but i can seem to find another solution...
Mark M.
Actually, my books focus on the views-in-tabs approach
you will see that in _The Busy Coder's Guide to Android Development_ and _Android Programming Tutorials_
fitz
has entered the room
Mark M.
howdy, fitz!
fitz
morning just getting started today so no questions
Mark M.
you don't want me to ask you any questions in the morning?
oh, no, wait, that's a question...
:-)
fitz
na that is my status - your well into your morning - past coffee time
10:25 AM
Mark M.
well, if anyone has a question, chime in
fitz
I noticed through some emails that your planning to do section on voice recognition - huge need for this?
Mark M.
I don't think it's super-popular
which is one of the reasons it's on the back burner
10:30 AM
Mark M.
my focus tends to be either on itches of my own that I am scratching, or itches that I think a lot of developers have
hence, I'd rather focus on memory management and Honeycomb and stuff now than voice recognition
not that voice recognition is bad, hard, or anything -- it's just not as critical for as many people
fitz
ya not main stream yet
Dimitri
If i was to implement a solution using the views-in-tabs approach how exactly would I load only the data require in each view. I.e http request per tab?
10:35 AM
Mark M.
put a ListView in each tab, but do not set an adapter right away
register an OnTabChangeListener with the TabHost
when the tab becomes active, you then know to load your data
Dimitri
using an intent to TripActivity...
Mark M.
well, if TripActivity used to be what were in the tabs, there would be no TripActivity if you switch to views-in-tabs
Dimitri
Again it would be 7 lists view in the tabhost correct?
Mark M.
yes
10:45 AM
Dimitri
I would have to call spec.setContent(R.id.list{id}); in each case?
Mark M.
yes
or, if you prefer, you could not have the ListViews in the XML and use a TabContentFactory
what would be nice here is an equivalent of the old VB TabStrip control, which gave you tab buttons but made no assumptions about what happened on a tab button press
in that case, you would use a single ListView and change up the adapter on a tab change
I have not tried using TabWidget this way, but I suspect it will only work with a TabHost
10:50 AM
Dimitri
How anout a custom Viewflipper instead?
Mark M.
I don't know how that would help
Dimitri
Thanks for your time as always valuable info i will have to read up on what we discussed.
fitz
do you think it is best to have logic and time set aside to re-do an app just for tablets - so can most code work with tweeks - I guess what I am asking if if apps now should be only for cells and then start from scratch for tablets and market it that way?
Mark M.
that's difficult to answer in the abstract
the problem with "start from scratch for tablets" is that tablets will be able to get at your phone edition
fitz
talking business apps not games etc.
Mark M.
though you can try the new <compatible-screens> element to try to keep tablet users from seeing the phone apps
10:55 AM
Mark M.
the only way, IMHO, it's clearly desirable to have a separate tablet-only app is if that's your sales model (e.g., phone app is free, tablet app with more features costs $$$)
otherwise, I'd try to have one app supporting all form factors
in theory, fragments and the Android Compatibility Library will help here
after my weekend of fighting with fragments, the acronym of ACL for that library seems apropos -- in other words, ow.
fitz
ok thanks for info will ponder ...... till next time have a GREAT day
Mark M.
you too!
fitz
has left the room
11:00 AM
Mark M.
OK, today's chat is over
next one is Thursday at 4pm Eastern Time
have a pleasant day!
Dimitri
has left the room
Mark M.
turned off guest access

Thursday, April 7

 

Office Hours

People in this transcript

  • Dimitri
  • fitz
  • Mark Murphy

Files in this transcript