Office Hours — Today, September 28

Thursday, September 23

Sep 28
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
10:05 AM
Evan
has entered the room
Evan
howdy, Mark
Mark M.
howdy, Evan!
how can I help you today?
10:10 AM
Evan
Mark, I'm having a good bit of trouble getting my SeekBar to take on the appearance that my designer has planned for me...
10:10 AM
Mark M.
those darn designers
always making trouble
:-)
Evan
hahaha
here's what it's supposed to look like: drop.io/mwqzswr
Mark M.
eek
Evan
i see that you can set a progress drawable, but when i do that, it almost seems to override the other two states, and thus void the purpose of having them explicitly defined...
forget the magnifying glass ;-)
Mark M.
oh, ok
that was the source of the eek
which "other two states" are you referring to?
Evan
though that is a distant, unrelated question
basically the unloaded and loaded, but not yet played states
i know the "played" state is "progress"
Mark M.
SeekBar doesn't know about "unloaded" and "loaded" and "not yet played"
Evan
and I've changed the scrubber to look right, but it still seems to want to control how it is positioned, etc.
Mark M.
I have successfully changed the colors on a ProgressBar, and SeekBar should follow the same pattern AFAIK
<layer-list> XML drawable
Evan
oh wow!
Mark M.
android:id="@android:id/background" for the normal state
Evan
really?
10:15 AM
Mark M.
android:id="@android:id/progress" for primary progress
android:id="@android:id/secondaryProgress" for secondary progress
Evan
ah--there's the distinction--primary and secondary progress
Mark M.
right
in my case, this was also for a video player
Evan
cool--I'll try that out
Mark M.
they used secondary progress for buffering, and primary progress for the playback position
Evan
that'll be the same for my case
Mark M.
in my case, the three layers were each <shape> drawables, with defined stroke, corners, and gradients
this was for a consulting contract, so I can't give you the full file
Evan
ah!
i understand...
so it is doable then...
i've been having this history of thinking something is doable in an Android control, then having to write it myself
like a horizontal list view
Mark M.
a "horizontal list view" sounds a bit like Gallery
Evan
now that magnifying glass--is anything like that even remotely doable in Android's framework?
Mark M.
can you have a circle? yes
Evan
it's a lot like gallery, except with some key behaviors changed
Mark M.
can you have stuff inside a circle? yes
can you have stuff inside a circle that represents a magnified view of something else that would have been obscured by the circle? eek
Evan
but filling that circle with a zoomed-in version of the area around the scrubber?
haha
Mark M.
I have no idea how to pull that off
it's not to say it's impossible, just that I haven't the foggiest notion even of where to start looking
Evan
but ostensibly, the circle could be drawn to look a lot LIKE it is just a magnified version...
10:20 AM
Mark M.
well, if it weren't for the overlap with the SeekBar, yes
I'm not even sure how the user uses what you have in that screenshot
if you drag the thumb, does the magnified area move?
Evan
hmm... so having it's visibility become visible when the seekbar is being dragged... no dice?
Mark M.
and if so, what happens at the beginning and end, when the circle impacts the edges of the screen?
Evan
that's the idea
i would assume the edge outside the screen would just be clipped
but that's a long can of worms that my designers are already not expecting me to do... so maybe on a rainy day or something
Mark M.
well, having a circle become visible/invisible when the thumb is dragged should be possible
yeah, and those worms have sharp pointy teeth
Evan
so another question on selectable list items, and representing the selection/focus state other than a drawable that is painted over the entirety of the list item with some opacity...
Mark M.
I have examples of that in The Busy Coder's Guide to Advanced Android Development
Evan
oh really?
Mark M.
on the whole, it's not a recommended technique, since it may confuse users
Evan
hmm... i must have overlooked them
Mark M.
chapter on ListView
10:25 AM
Mark M.
I should have the Flying Fickle Finger of Fate example, using a hand to point at the selected item
Evan
that blue background is the "pressed" state
Mark M.
pressed?
Evan
whereas a green background in the same place would be the focused state
like if the user presses the middle directional button to "select" that list item
Mark M.
no, that's the "selected" state
not sure if "pressed" is used in ListView
I see that mostly on Button/ImageButton
Evan
oh really?
so that distinction is actually quite important in getting this to work right?
Mark M.
getting the state right is important, yes
Evan
either way you say there is an example in the BCGAAD?
Mark M.
first, the link above is for ColorStateList, but it lists all of the possible states
with regard to BCGAAD, I have an example of using an OnSelectionChanged listener to adjust row Views to show the current selection
it'd be better if you could get it working with StateListDrawable/ColorStateList and states, but my technique generally works
Evan
and that technique is mentioned in BCGAAD?
Mark M.
the OnSelectionChanged approach, yes
there is some light hand-waving regarding StateListDrawale and ColorStateList, but not much
need to beef that up someday
Evan
but not the StateListDrawable/ColorStateList approach
ah gotcha
just knowing that it is doable gives me the steam to move forward
10:30 AM
Will T.
has entered the room
Mark M.
howdy, Will T!
Will: got a question?
Evan
i have another one whenever i have the floor again... (let Will go first though)
Will T.
Hi Mark, you responded to a Stack Overflow question I had last night (http://stackoverflow.com/questions/3810480…) with something I though I had tried (just overriding the view with a ListView). The problem was overriding the Adapter to handle the enabling and disabling. What am I misunderstanding?
Thanks Evan...
Mark M.
you should not need to override the adapter
10:35 AM
Mark M.
ListView in CHOICE_MODE_MULTIPLE stores the checked states itself
you need to use a layout with a CheckedTextView
Will T.
I understand that and have seen it. My problem seems to be when I try to limit how many are checked.
Mark M.
use setItemChecked() to pre-check anything
oh
oops
Will T.
Ah, that is probably what I missed
Mark M.
more, I missed that in your question
Will T.
ok
Mark M.
alas, there's no event on a check
which stinks
so, yeah, you're probably going to have to reinvent the checked-item wheel
Will T.
which is why I went the harder way and created a child of ListView to handle the adapter. That way in the isEnabled I could do my checking
Mark M.
isEnabled() has nothing to do with checkboxes, though
Will T.
But when I mark one of the checkboxes as checked in isEnabled, it does not stick
Mark M.
that indicates whether the row itself is clickable
Evan
howcome Mark's answer isn't on that stackoverflow page?
Mark M.
Evan: it was a comment
Evan
oh
Mark M.
Will: you might want to take a peek at The Busy Coder's Guide to Android Development, in the Fancy ListViews chapter
I show there how to have a RatingBar in rows of a ListView
Will T.
I started there... :)
Mark M.
the same technique should work for you with CheckBox widgets
Will T.
Do I need to do something in:
View paste
public void onItemClick(AdapterView<?> parent, View child, int position, long id)  
    { 
        // For now we don't need anything... 
        // we think the ItemAdapter manages what we need for each item. 
 
    }       // void onItemClick(AdapterView<?> parent, View child, int position,
Mark M.
only if you want to toggle the checkbox if they click on the row itself
you need to hook up OnCheckChanged listeners on each checkbox
10:40 AM
Will T.
Should I manage my enabling & disabling there, instead of in isEnabled?
Mark M.
yes
Will T.
ooooh! that sounds nasty
Mark M.
yeah, well
I never promised you a rose garden
Will T.
ok, if that is the way, that is what I have to do. <shrug>
Thanks!
:)
Mark M.
isEnabled() could conceivably work, but I don't think it will get called when you need it called, that's all
Will T.
its getting called but changes I make in it are not reflected
Mark M.
and, isEnabled() would probably need to enable/disable the checkbox as well
Will T.
that is what I was trying but the checks don't stick when I set them there
Mark M.
define "don't stick"
Will T.
If something is checked on the UI. It does not remain checked after the isEnabled code runs. That was true before I decided to try to "reset" it in isEnabled which is what the code is currently doing.
When I return to the UI the checkbox is not checked
Mark M.
oh, well, there are problems in your code :-(
you can't go by the checkboxes to determine what is checked
checkboxes get recycled
you need to be storing the checked states in your data model
Will T.
ok
Mark M.
again, I refer you to the RateList sample from The Busy Coder's Guide to Android Development
Will T.
I'll double check what I missed from the sample
Thanks, again
10:45 AM
Will T.
Is there a way to copy the conversation?
Mark M.
I'll be posting a link to the transcript on the [cw-android] Google Group after the chat is over
Will T.
ok, great!
Mark M.
Evan: you had another question?
Evan
yeeessss
Frank S.
has entered the room
Frank S.
Hi Mark. Thanks for the email
Evan
alright, so I've got this control that is essentially a LinearLayout that I'm adding children to (as a "Stack")
Mark M.
howdy, Frank S!
Evan
and I call methods that update result in updates to the child widget list (as in how many children are in it) fairly frequently
it seems though that the changes are not taking effect, randomly
I'll add widgets to it, and despite giving them the proper layout params (which ive verified while debugging)
their width and height are 0
and this is despite calls to requestLayout() and invalidate() on various parts of that hierarchy...
is there some minutiae I am overlooking here?
Mark M.
tough to answer that
you might consider using hierarchyviewer to help debug
Evan
am I maybe hitting some weird throttling mechanism I didn't know existed?
Mark M.
"throttling"?
10:50 AM
Mark M.
bear in mind that you can't find out the width and height until the widgets are laid out on the screen
Evan
right, and they're not getting laid out
Mark M.
so, if the width and height are physically correct (according to hierarchyviewer), but you cannot access the values from code, you're asking too early
ok
Evan
i've verified that i've added them, and everything has wrap_content
Mark M.
then break open hierarchyviewer, double-check your rules, and figure out who is eating the space, or if there's another problem (e.g., you're invisible, you're behind something else)
Evan
interesting... never heard of that
HierarchyViewer
Mark M.
covered in the Development Tools chapter of The Busy Coder's Guide to Android Development
Evan
ah... must have overlooked that part!
;-)
thanks!
Mark M.
Frank: did you have a question?
Frank S.
yes
what do you feel is the best way to create a pdf of the current screen
we basically want to take a screen shot and convert that into a pdf
but I believe that screen res will play a negative part in that process
Mark M.
open DDMS, take a screenshot, open that in some image viewer, and print to PDF
with some Java coding, you could create a tool to run on the desktop that would automate some of that
Frank S.
that will not be an option. We need to do this programatically and without root access
Mark M.
if you are looking for it to run on the device, you're out of luck
not possible
Frank S.
it there something we can do to generate a pdf
10:55 AM
Frank S.
like reconstrust the views and layout and object
and just convert that into a pdf
Mark M.
that depends on how many developer-months you have
for example, you could try to leverage the preview pane from Ecipse
er, Eclipse
however, that has limits, particularly with custom widgets
and, that too does not run on the device
Frank S.
it doesn't have to be the current screen since we already have the information populating all the field.
no. it needs to run on the device. We are working on a banking app
Mark M.
if this is your own activity, there is a way to get an image of what you have drawn -- I was thinking you were trying to get the images of other activities
Frank S.
to write checks
Mark M.
what does that have to do with screenshots and PDFs?
Frank S.
the screen shot is the current view of the check
Mark M.
so?
Frank S.
we want to generate a pdf of the current screen
because that will be the "check"
Mark M.
that makes no sense
Frank S.
That will work, because this will be our own activity
Mark M.
you already have an image of the check
that's what you are showing on the screen
why are you taking a screenshot of an image you already have?
Frank S.
The screen is displaying our generate check will all the information
Mark M.
oh
Frank S.
no. that was my question I guess
we can generate an image to convert to a pdf from what we were displaying on the screen
11:00 AM
Mark M.
you might be able to use getDrawingCache() to get a Bitmap from your base View
Frank S.
ok great. That gives us a nice place to start plugging away
Mark M.
rather than generate the PDF on-device, though, I suspect you may want to have a server do that
might be slow
or, just send all the details to the server, and have it generate the PDF
skipping the screenshot
OK, that wraps up the chat for today
Frank S.
point taken. We will test this. Since banking information is sensitive we were trying to avoid as much as possible
thanks mark
Mark M.
next one is Thursday, in the evening US Eastern Time
have a pleasant day, all!
Evan
has left the room
Will T.
has left the room
Frank S.
has left the room
Mark M.
turned off guest access

Thursday, September 23

 

Office Hours

People in this transcript

  • Evan
  • Frank Sposaro
  • Mark Murphy
  • Will Tartak

Files in this transcript