Office Hours — Today, July 26

Tuesday, July 24

Jul 26
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
10:00 AM
scottt
has entered the room
Mark M.
howdy, scottt!
scottt
good morning
Mark M.
how can I help you today?
scottt
I finally have a real question...
View paste
I'm doing some Blackberry->Android migration work for a client and need to acquire the (application) context from within a non-activity class in order to access some resources. The client would like to keep the API the same, so passing in the context is not ideal.
View paste
I've seen some stuff (http://stackoverflow.com/questions/2002288/static-way-to-get-context-on-android) about creating a class that extends Application and provides a method that returns the context. But I don't think that will work for me since I'm just doing the utility functions and not the whole application.

Any recommendations?
Mark M.
um, if you can't change the code, I don't know how you can change the code
you either need to change the code to pass in a Context, or you need to do the whole expose-the-Application-singleton thing
either way involves changing code
scottt
i can change the code, i'm just not supposed to change the api
Mark M.
then create the Application subclass that exposes the singleton
(I'm not a huge fan of this, as it encourages some lazy programming, but it should be generally safe)
scottt
but then i'd have to name the application in the manifest, wouldn't i?
Mark M.
yes
10:05 AM
scottt
i suppose the underlying question here, is how should a library type thing access the application class (w/o accepting the context directly)?
Frank S.
has entered the room
scottt
it sounds like the short answer is: "it can't"
Mark M.
you have no choice in a library but to "accept the context directly", unless part of the library implements things that extend Context (e.g., Activity)
(BTW, howdy, Frank!)
scottt
ok. thx. i'll have to just pass that on to the client
Mark M.
Frank: do you have a question?
OK, if either of you have a question, chime in
Frank S.
Yes. I'm trying to create a DialogFragment, but my OnClickListener for the Views do not seem to be getting called. Perhaps I'm having a minor misunderstanding between the View's onClickListener and the Dialog Interface OnClickLIstener
Mark M.
DialogInterface's OnClickListener is for the dialog's buttons (setPositiveButton(), etc.)
since they are different interfaces, you cannot mix and match DialogInterface.OnClickListener and View.OnClickListener
10:10 AM
Frank S.
Ok cool. I've just been using the View's OnClickListener, but it doesn't see to want to be called :(
Mark M.
unfortunately, I do not have a ready example of attaching listeners to the Views inside a dialog
mostly because I don't much care for dialogs
but, AFAIK, it should work normally
10:15 AM
Mark M.
if anyone has a question, chime in
10:40 AM
scottt
i don't have anything more. thank you for your expertise.
Mark M.
happy to be useful!
Frank S.
lol. I'm trying to get on your level on StackOverflow. What's the secret? I stopped wasting my time answering questions for users with low points because they don't upvote :p
Mark M.
the secret? answer 7,659 questions, I suppose
Frank S.
lol
Mark M.
I'm really not in it for the upvotes or score or whatever
Frank S.
I've been working on it. Yeah, but it's nice to get feed back. I don't like trying to help someone and have them disappear on me. It's nice to know either my advice worked or didn't. Especially since I'm always trying to learn too.
10:50 AM
Frank S.
Oh. That's right. Do you have any tricks for rounding the corners of a ListView?
Mark M.
well, `ListView` is intrinsically rectangular, but with a transparent background by default
if you give it a background that has rounded corners (e.g., ShapeDrawable), I would expect that the visual effect would be for the ListView to have rounded corners
but I have never tried this
Frank S.
ok. We will have to try that.
10:55 AM
Mark M.
any last questions?
Frank S.
nope.
scottt
nope. i'm good. until next time...
scottt
has left the room
11:00 AM
Mark M.
OK, well, that's it for today's chat
11:00 AM
Frank S.
thanks mark
Mark M.
next one is Tuesday, 4pm Eastern
have a pleasant day!
Frank S.
has left the room
Mark M.
turned off guest access

Tuesday, July 24

 

Office Hours

People in this transcript

  • Frank Sposaro
  • Mark Murphy
  • scottt