Apr 18 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Apr 18 | 4:00 PM |
Tamir | has entered the room |
Tamir |
hi
|
Mark M. |
hello, Tamir
|
Mark M. |
how can I help you today?
|
Spleak | has entered the room |
Tamir |
View paste
|
Mark M. |
I doubt that you can safely change the contents of a ViewPager that way
|
Mark M. |
ViewPager is designed to allow horizontal swiping between peer content
|
Spleak |
Hi
|
Mark M. |
(Spleak: hi! I will be with you shortly!)
|
Tamir |
but still i cant load a new fragment in the same tab ?
|
Tamir |
i am using some farame layer
|
Mark M. |
Tamir: you can call notifyDataSetChanged() and perhaps return a different fragment
|
Mark M. |
however, I will be surprised if addToBackStack() will work
|
Mark M. |
because you should not be executing the FragmentTransaction -- your adapter will
|
Mark M. |
it is conceivable that you could create your own PagerAdapter implementation that can handle this scenario better
|
Mark M. |
since I really really really dislike the navigation pattern you are proposing, I have not given this much thought
|
Apr 18 | 4:05 PM |
Mark M. |
let me take a question from Spleak, and I will be back with you in a bit
|
Mark M. |
Spleak: do you have a question?
|
Tamir |
ok thanks
|
Spleak |
Yes I do
|
Spleak |
View paste
|
Spleak |
(just pasting it all)
|
Spleak |
View paste
(2 more lines)
|
Mark M. |
I'd look to see how iosched does it
|
Spleak |
Also I can wait for an answer, just write here if it takes long you can help Tamir
|
Mark M. |
iosched is the Google I|O conference app
|
Spleak |
Hmm okay :O
|
Mark M. |
it has a calendar akin to what you are proposing, though a bit more complex (shows all rooms, not just one)
|
Mark M. | |
Mark M. |
the HTML approach could work
|
Mark M. |
you could hack something together using a TextView
with a nine-patch PNG file for the background (for a variable-size
bubble) and appropriate margins
|
Spleak |
Is it the "my agenda" part of the IO app you are talking about?
|
Mark M. |
(in a vertical LinearLayout, wrapped in a ScrollView)
|
Mark M. |
yes
|
Mark M. |
well, sorta
|
Apr 18 | 4:10 PM |
Mark M. |
there's also a separate view for the conference agenda
|
Mark M. |
not shown in the screenshots
|
Mark M. |
it's been nearly a year since I looked at it, so my memory is fuzzy
|
Spleak |
Ah, downloading the app and looking right now
|
Spleak |
The "Textview"-hack, how exactly do you mean? Still use a ListFragment?
|
Mark M. |
no
|
Mark M. |
have one TextView per event
|
Mark M. |
size the TextView vertically in accordance with its duration
|
Mark M. |
using the nine-patch PNG to give you the rounded-rectangle "bubble" for the event
|
Mark M. |
use margins for the spacing between events, sized in accordance with the duration of the gaps
|
Mark M. |
using a vertical LinearLayout for the whole thing
|
Mark M. |
wrapped in a ScrollView so that it is scrollable
|
Spleak |
Ahh I understand. That actually sounds pretty good
|
Mark M. |
getting the sizing and margins right may get a bit tricky
|
Mark M. |
another variation on the theme would use a
FrameLayout instead of a vertical LinearLayout, using the top margin to
offset the TextView to the right spot
|
Spleak |
Ye. Especially since I want it to scale for many screensizes.
|
Mark M. |
go that route if you find that you are
progressively getting further off due to calculation issues compounded
as you append more and more events
|
Mark M. |
you could even create your own ViewGroup with this sort of model in mind
|
Mark M. |
so, there are lots of possibilities
|
Apr 18 | 4:15 PM |
Spleak |
Figured so. :) Thanks for the great tips. I will try to find how Google did with their IO thing (still can't find it).
|
Mark M. |
let me swing back to Tamir, and I'll be with you again in a bit
|
Mark M. |
Tamir: do you have another question?
|
Spleak |
sure
|
Mark M. |
OK
|
Tamir |
yes .. one more
|
Mark M. |
go ahead
|
Tamir |
i thought to try and catch the on press Back button event and the activity
|
Tamir |
on the main activity
|
Tamir |
can i tell which fragment is running when the event happend?
|
Mark M. |
all of your fragments are "running"
|
Mark M. |
for any conventional definition of "running"
|
Mark M. |
what do *you* mean by "running"?
|
Tamir |
the one that user use just before he pressed the back button
|
Mark M. |
I have no idea what you are talking about
|
Apr 18 | 4:20 PM |
Mark M. |
what does "that user use" mean?
|
Tamir |
never mind thanks for the help
|
Tamir |
let say that i use the fragment manager and just replaced a fragment
|
Mark M. |
...and... ?
|
Tamir |
and than the user pressed back
|
Tamir |
and i want for the replaced fragment to handle this event
|
Mark M. |
you will have to track that yourself
|
Mark M. |
again, you will have to track that yourself
|
Tamir |
thanks
|
Tamir |
thanks for your help
|
Mark M. |
Spleak: do you have another question?
|
Spleak |
Hmm. Well not anything I can't read myself to I think. Still can't find where in the IO app the schedule is though. :)
|
Mark M. |
it's possible I was thinking of the 2011 edition
|
Apr 18 | 4:25 PM |
Mark M. |
then if either of you has a question, chime in
|
Spleak |
Will do, thanks for the help! Just gonna hang around here
|
Apr 18 | 4:35 PM |
Spleak |
Just one quick question. Trying your "textview"-method. You mean set the 9-patch png as the background for the textview right?
|
Spleak |
(probably silly question)
|
Tamir |
bye and have a good day
|
Mark M. |
correct, whatever you want the event background to look like
|
Tamir | has left the room |
Mark M. |
you'll need to set the height and width to whatever makes sense (height based on duration, width presumably match_parent)
|
Spleak |
ya. and I can only set the height in Java right?
|
Mark M. |
in your case, yes, because you do not know the duration of the event at compile time
|
Spleak |
exactly. :) Also, how should I do to print out the
"times"? I want there to be like 24 "lines" with each hour, which the
bubbles are then placed "on top" of if you get what I mean
|
Mark M. |
that will probably require you to go the FrameLayout route and use margins to "push down" each bubble/line from the top
|
Spleak |
or perhaps that's not needed.. hmm
|
Mark M. |
(or roll your own ViewGroup)
|
Apr 18 | 4:40 PM |
Spleak |
Okay. Never used FrameLayout before. So I still go
the same route with making a TextView+background, just use the
FrameLayout to position it instead, modifying the margin according to
the time they are (and ofc heigh or the textview for how long)?
|
Spleak |
height of*
|
Mark M. |
yes
|
Mark M. |
FrameLayout is a fairly simplistic container, that
puts everything in the upper-left corner by default, and stacks on the Z
axis (later children float over earlier children)
|
Mark M. |
if you want lines, with events floating over them, you need a container that has Z axis support, and LinearLayout does not
|
Spleak |
hmm okay. So I should make a new element, representing a "line with time" and add those as a child, and then add my textviews?
|
Mark M. |
yes
|
Mark M. |
actually, 24 elements, each representing a "line with time"
|
Mark M. |
(where 24 = however many hours you are showing, and adjust if you are showing time divisions other than an hour)
|
Spleak |
Ah. And how do I do to position the "bubbles" over them? Won't they just push the lines further down?
|
Spleak |
if I get what you wrote earlier correctly
|
Mark M. |
no, because children in FrameLayout are independent of each other on the X/Y plane, unlike with LinearLayout
|
Mark M. |
you set the top margin for each child to be how far from the top you want it to appear
|
Mark M. |
and you order them, in terms of when you add them as a child, to determine the Z-axis stacking
|
Spleak |
so I can for example add 1 element and set the
margin to like. 50? and then another and set it to 50 also, then they
will overlap each other?
|
Mark M. |
yes
|
Spleak |
Ah, fantastic :)
|
Spleak |
can I rearrange the child-elements however I want?
|
Mark M. |
yes, by adding and removing them
|
Mark M. |
there is no setZAxisOrder() or equivalent method
|
Apr 18 | 4:45 PM |
Mark M. |
if you mean rearrange in terms of the chronology, that's a matter of adjusting the LayoutParams of the widget at runtime
|
Spleak |
ah great, think this is exactly what I'm looking for
|
Spleak |
the "line with time" element could be a textview with a drawable? (sorry for the newbie questions, still learning android)
|
Mark M. |
conceivably -- haven't tried that for this scenario
|
Mark M. |
if not, a LinearLayout with a TextView and a View as children
|
Mark M. |
(View, given a background color, is good for lines or boxes)
|
Spleak |
there is no equivalent to <hr> in android? :)
|
Mark M. |
yes, a View with a width of match_parent, a height of whatever-you-want, and a background color of whatever-you-want
|
Spleak |
ah nice. then combine that with a textview in a linearlayout?
|
Mark M. |
that would work, yes
|
Apr 18 | 4:50 PM |
Mark M. |
the compound drawable technique with TextView is a tad more efficient, though that probably won't matter here
|
Apr 18 | 4:50 PM |
Spleak |
okay, thanks again =)
|
Spleak |
if I want the height (for example for the line) to
be a little bigger for screens with higher densities, I use "dp" as
unit right0
|
Spleak |
?
|
Mark M. |
right
|
Spleak |
great
|
Mark M. |
1dp = 1px at medium density (~160dpi)
|
Mark M. |
1dp = 2px at xhdpi
|
Mark M. |
and so on
|
Apr 18 | 4:55 PM |
Spleak |
the framelayout should be wrapped in a scrollview right?
|
Mark M. |
yes
|
Apr 18 | 5:00 PM |
Mark M. |
well, that's a wrap for today's chat
|
Mark M. |
the transcript will be posted shortly to http://commonsware.com/office-hours/
|
Mark M. |
next chat is Tuesday at 7:30pm Eastern
|
Mark M. |
have a pleasant day!
|
Spleak |
thanks! you too
|
Spleak | has left the room |
Mark M. | turned off guest access |