Office Hours — Today, November 7

Yesterday, November 6

Nov 7
3:55 PM
Mark M.
has entered the room
Mark M.
turned on guest access
4:00 PM
Peri H.
has entered the room
Peri H.
Hi Mark,
Mark M.
howdy, Peri!
how can I help you today?
Peri H.
I was asking you about EditText in a ListView the other day.
Mark M.
yes
Peri H.
The main thing is I want a TextView that looks like an EditText. At first I thought that might be hard to do, but I was able to change almost all my refs to EditText to TextView and use the TextView instead. The only remaining problem is making them look alike
Mark M.
why would you want something that looks like an EditText but is not an EditText?
won't the user get confused when trying to type?
Peri H.
What I discovered is that android uses styles.xml to set attributes for EditText. So, I was able to steal those and set them in my code. Ony probelm is that's pretty fragile.
To answer your question, I have a hierarchy where some things are editable and some are not. They all have to be large enough for a user's finger to tap on them. If editable, the user will be able to edit; if not, the user will get a popup dialog for editing.
Mark M.
um, OK
Peri H.
You'll have to see it eventually. There may be a better way, but it seems to work pretty intuitively.
Anyway, I have copied the background, textAppearance, textColor attributes into my code. But it's fragile because the style.xml could change or be different on different peoples devices and then my look will get messed up.
4:05 PM
Mark M.
that is particularly true on Android 1.x/2.x, where device manufacturers also change these things
Theme.Holo helps to insulate matters from device differences, but Google still makes changes
Peri H.
I thought the safer solution would be to use an EditText and change properties to make it behave like a TextView. It is a thin wrapper, after all. But, I couldn't figure out how to do that.
Mark M.
android:editable="false" was insufficient?
Peri H.
No. Can't remember why.
I think it still ate clicks.
Mark M.
it was hungry!
if you use your own styles for everything, it will not matter what the device is using
(by "everything" I mean TextView and EditText for the widgets in question)
you will be internally self-consistent
you might lack platform fidelity, compared to other apps, but that typically is of secondary importance
particularly on Android 1.x/2.x, where "platform fidelity" is a seriously moving target
Peri H.
Is that advisable? The lack of platform fidelity wont piss off users too much?
Mark M.
well, all else being equal, you'd prefer to look like other apps
you're already a bit outside the box, though, with an EditText that does not behave like an EditText
4:10 PM
Peri H.
Ok, I'll look up how to use thems. Haven't done that yet.
Is it themes I want?
Mark M.
themes and styles, yes
Peri H.
Cool.
Mark M.
this level of modification gets complicated, and I am *so* not an expert on it yet
Peri H.
Ok, I have a second issue. Are you willing?
Mark M.
nobody else is here, so fire away
Peri H.
I am using StartActivity to modify a contact displayed in my app. It pops up the dialog to edit the contact just fine, but upon completion, or "back", it goes to "people" list view of contacts. I suspect it's a bug in the "people" contact editor. What do you think?
Mark M.
by "back" you mean the BACK button, or a DONE item in the action bar?
Peri H.
Back button.
In particular my code is:
View paste
    Intent intent = new Intent (Intent.ACTION_EDIT);
View paste
    intent.setData (Uri.parse (ContactsContract.Contacts.CONTENT_LOOKUP_URI + "/" + key));
View paste
    getActivity().startActivity (intent);
4:15 PM
Mark M.
well, there's the whole mess that Google got us into, with the whole back-vs.-up thing
Peri H.
I posted this on StackOverflow, but no one answered. It's been several days.
Mark M.
where they advocate you create "synthetic back stacks" and such
so it's possible that you're seeing some aspect of that
do you have a link to the SO question handy?
Peri H.
Mark M.
what version of Android are you seeing this behavior on? does the behavior vary by version?
Peri H.
version 4.1.2. I could try it in the emulator with an earlier version, but that will take me a while. Can do and report back and send you an email.
Mark M.
my guess is that you will not see this behavior on Android 2.x
and that you are running into something specific to the contacts app
bear in mind, though, that ACTION_EDIT is not designed for startActivityForResult()
Peri H.
Yeah, that was an earlier try. startActivity is what I'm using now.
Mark M.
your onActivityResult(), if invoked, would be ACTIVITY_CANCELED always
yeah, I suspect that "it is what it is" for Android 4.x
4:20 PM
Mark M.
I am not aware of anything you can do in your Intent to say "no, please, let BACK come to me, rather than doing something else"
Peri H.
I can try android 3.1 - I think the apis I'm using are supported there. I targetted for 4.0 since that's soon going to the majority of users.
Mark M.
it does not matter what you are targeting
what you are running on is what matters
Peri H.
Well, it does because I wanted to use the action bar and some other stuff without learning how to use the backwards-compatible apis.
Maybe that wouldn't have been hard; I have no idea really.
Mark M.
I meant in terms of the behavior that you are seeing
Peri H.
True, but for me to ry version 2.0, I'd have to rework a lot of code.
Mark M.
ActionBarSherlock is not that tough -- the book covers it
you don't have to test on Android 2.x if you don't want to and are not planning on supporting it
my point was that I suspect that the behavior of the Contacts app changed in 4.0 (maybe even in 3.x) to what you are seeing
and that earlier versions of Android would have behavior that you (and I) would find more logical
Peri H.
Do you think it's an intentional change, or a bug?
I filed a bug report, but haven't heard back yet.
Mark M.
I suspect that it is an intentional change with an unintended side effect
but that is just a guess
Peri H.
Regardless, I need some sort of workaround. Maybe I should just search for and steal the code for "people" and make it go "back" to my prior activity.
Mark M.
that's likely to be a lot of code
Peri H.
Wha do you suggest?
4:25 PM
Mark M.
give me a moment for a bit of research
Peri H.
sure
Mark M.
hmmmmm
looking at the source to the Contacts app, I don't see anything that would trigger the behavior that you are describing
I would recommend that you create a sample app that demonstrates the behavior
post a link to that sample app in the issue and the SO question
Peri H.
I just realized my sample app (shown in the SO entry) could be dialed back to 2.0. I'll try that.
Mark M.
post an @CommonsWare comment in the SO question to let me know when the link is ready
I'd like to run some experiments
Peri H.
I don't follow you.
The sample app has been there. I also posted it to android with the xml files. I can give you that link if I can figure out how to find it.
Mark M.
the SO question has just a bit of code, and no link to a sample app (or any links at all)
4:30 PM
Peri H.
Right, so I'll get you the link for the bug report. I'm trying to figure out how to look up bugs I filed but don't see a UI for that.
Mark M.
there's the search field right on http://b.android.com
and the Advanced Search link on the same page
Peri H.
Try this:
http://code.google.com/p/android/issues/de… Type Status Owner Summary Stars
Mark M.
next time, I would recommend that you ZIP up the whole project tree and post that
your objective with an issue is to make it as easy as possible for somebody to follow up on it
Peri H.
Ok. Is that the usual protocol?
Mark M.
it's certainly the recommended protocol
for example, your manifest has an entry for SecondActivity, which you did not upload
Peri H.
If I were to try it with 2.0, though, I would need a device with 2.0 installed on it, right? Otherwise my app would be targetted for 2.0 but still be using the version of "people" shipped with 4.0.
4:35 PM
Peri H.
Right, I get the zipfile idea. Next time for sure.
Mark M.
to test on any Android version, you need a device or emulator running that version
Peri H.
I'd be happy to zip it for you if you're really going to try it.
Mark M.
having looked at the Contacts code, I have an idea of what they're doing, but having a complete project that demonstrates the problem would help
Peri H.
I can try it myself in an emulator. Regardless, it's failing on 4.x and that's what people will be running. What am I going to learn by trying on 2.x?
Mark M.
(and I'm unconvinced that there's a workaround for you)
well, relatively few people have 4.x
if you are only planning on shipping 4.x, then don't worry about 2.x
Peri H.
It's about 29% now and I'll guess by jan or feb it will be 70%
Mark M.
again, I only mentioned it because most Android developers are still supporting 2.x, and I thought that it would be a trivial test for you to see the difference in behavior
um, no
it won't get to 70% for at least a yhear
er, year
I'll be happy to be wrong on that point
Peri H.
Ok, if you say so. I'm only guessing.
Mark M.
but the Gingerbread users won't all be getting upgrades or replacing their devices
Peri H.
Regardless, I don't want to fail on the existing 29%.
Mark M.
understood
which is why I suggest that you make a complete project available that demonstrates your problem
4:40 PM
Mark M.
so that I can take a look at it
Peri H.
Ok, I have it. Just need to zip it. Should I reattach it to the bug report?
Mark M.
I'd attach it to the bug report, then add a comment on the SO question with a link to the bug report
that way, the project is accessible from both places
(and SO doesn't let you upload files the way b.android.com does)
Peri H.
Will do. Shall I drop you email when I've done that? Might be tonight as I have a meeting to go to soon.
Mark M.
if you think of it, when you add the comment on the SO question with the link, add @CommonsWare to it, and that will put it on my radar
I'll tend to do follow-ups on the SO question, unless I have something fairly concrete that makes sense for the bug tracker
Peri H.
I'm not familiar with the SO notification mechanism. Where do I do that?
Mark M.
in your question, underneath the tags, you will see a "comment" link
click that
enter the following:
@CommonsWare: here is the link to the bug report and sample project: ....
(where .... is your URL)
the @CommonsWare means that SO will notify me about the comment
you use the @ notation typically for replies to people in the discussion of the question and answers
much like @ references on Twitter
(which I suspect is where they mooched the notation)
Peri H.
Oh, so that notifies you immediately? I've found SO to be rather lacking in notification. I have to keep refreshing my browser to see what changed.
4:45 PM
Mark M.
On the top of any SO page, in the upper left, you will see "StackExchange"
bsr
has entered the room
Mark M.
with icons to the left and right
if somebody puts an @ reference to you in a comment, the left icon will turn into a red dot with a 1 as a message counter
and clicking the drop-down arrow icon on the right will fold open a notification panel, with a link to the comment where you were referenced
(BTW, howdy, bsr -- be with you momentarily!)
bsr
No problem :-) .. Thanks
Mark M.
this may not work for you yet because you have low karma (that 44 score beneath your name in your question)
Peri H.
Ok, yes I've seen that. I'll get there. Thanks for your help. I'll go out for now.
Mark M.
OK
bsr: do you have a question?
bsr
ya.
I initialize a cutom adapter like
View paste
  public void onActivityCreated(Bundle savedInstanceState) {
..
ListAdapter sla = new ListAdapter(getActivity().getApplicationContext(),null) ;
lv.setAdapter(sla);
data is initially null
I would populate it later through http call..
it crashes
with null pointer error
so, where else can I set the adapter
may be after the data received from server
Mark M.
first, what does ListAdapter inherit from?
bsr
ListAdapter extends ArrayAdapter<JSONObject> {
Mark M.
OK, I do not think that ArrayAdapter supports null
typically, you would not set the adapter until onPostExecute() of the AsyncTask where you are doing the HTTP request, or something like that
4:50 PM
Mark M.
it has to be on the main application thread (hence the onPostExecute())
but there is no sense in providing an empty ArrayAdapter, so you wait until you have your data
bsr
oh ok, I thought it may need along with view initialization
ok, I will do it in then my call back
thanks Mark
that;s it
Mark M.
OK
bsr
Have a good evening
Mark M.
you too!
bsr
has left the room
Mark M.
Peri: if you are still here and have further questions, go ahead
Peri H.
has left the room
5:00 PM
Mark M.
turned off guest access

Yesterday, November 6

 

Office Hours

People in this transcript

  • bsr
  • Mark Murphy
  • Peri Hartman