Nov 7 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Nov 7 | 4:00 PM |
Peri H. | has entered the room |
Peri H. |
Hi Mark,
|
Mark M. |
howdy, Peri!
|
Mark M. |
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?
|
Mark M. |
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.
|
Peri H. |
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.
|
Peri H. |
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.
|
Nov 7 | 4:05 PM |
Mark M. |
that is particularly true on Android 1.x/2.x, where device manufacturers also change these things
|
Mark M. |
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.
|
Peri H. |
I think it still ate clicks.
|
Mark M. |
it was hungry!
|
Mark M. |
if you use your own styles for everything, it will not matter what the device is using
|
Mark M. |
(by "everything" I mean TextView and EditText for the widgets in question)
|
Mark M. |
you will be internally self-consistent
|
Mark M. |
you might lack platform fidelity, compared to other apps, but that typically is of secondary importance
|
Mark M. |
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
|
Mark M. |
you're already a bit outside the box, though, with an EditText that does not behave like an EditText
|
Nov 7 | 4:10 PM |
Peri H. |
Ok, I'll look up how to use thems. Haven't done that yet.
|
Peri H. |
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.
|
Peri H. |
In particular my code is:
|
Peri H. | |
Peri H. | |
Peri H. | |
Nov 7 | 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
|
Mark M. |
so it's possible that you're seeing some aspect of that
|
Mark M. |
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
|
Mark M. |
and that you are running into something specific to the contacts app
|
Mark M. |
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
|
Mark M. |
yeah, I suspect that "it is what it is" for Android 4.x
|
Nov 7 | 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
|
Mark M. |
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.
|
Peri H. |
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
|
Mark M. |
you don't have to test on Android 2.x if you don't want to and are not planning on supporting it
|
Mark M. |
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
|
Mark M. |
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?
|
Peri H. |
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
|
Mark M. |
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?
|
Nov 7 | 4:25 PM |
Mark M. |
give me a moment for a bit of research
|
Peri H. |
sure
|
Mark M. |
hmmmmm
|
Mark M. |
looking at the source to the Contacts app, I don't see anything that would trigger the behavior that you are describing
|
Mark M. |
I would recommend that you create a sample app that demonstrates the behavior
|
Mark M. |
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
|
Mark M. |
I'd like to run some experiments
|
Peri H. |
I don't follow you.
|
Peri H. |
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)
|
Nov 7 | 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
|
Mark M. |
and the Advanced Search link on the same page
|
Peri H. |
Try this:
|
Peri H. |
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
|
Mark M. |
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
|
Mark M. |
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.
|
Nov 7 | 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)
|
Mark M. |
well, relatively few people have 4.x
|
Mark M. |
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
|
Mark M. |
um, no
|
Mark M. |
it won't get to 70% for at least a yhear
|
Mark M. |
er, year
|
Mark M. |
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
|
Mark M. |
which is why I suggest that you make a complete project available that demonstrates your problem
|
Nov 7 | 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
|
Mark M. |
that way, the project is accessible from both places
|
Mark M. |
(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
|
Mark M. |
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
|
Mark M. |
click that
|
Mark M. |
enter the following:
|
Mark M. |
@CommonsWare: here is the link to the bug report and sample project: ....
|
Mark M. |
(where .... is your URL)
|
Mark M. |
the @CommonsWare means that SO will notify me about the comment
|
Mark M. |
you use the @ notation typically for replies to people in the discussion of the question and answers
|
Mark M. |
much like @ references on Twitter
|
Mark M. |
(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.
|
Nov 7 | 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
|
Mark M. |
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
|
Mark M. |
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
|
Mark M. |
(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
|
Mark M. |
bsr: do you have a question?
|
bsr |
ya.
|
bsr |
I initialize a cutom adapter like
|
bsr |
View paste
|
bsr |
data is initially null
|
bsr |
I would populate it later through http call..
|
bsr |
it crashes
|
bsr |
with null pointer error
|
bsr |
so, where else can I set the adapter
|
bsr |
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
|
Mark M. |
typically, you would not set the adapter until
onPostExecute() of the AsyncTask where you are doing the HTTP request,
or something like that
|
Nov 7 | 4:50 PM |
Mark M. |
it has to be on the main application thread (hence the onPostExecute())
|
Mark M. |
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
|
bsr |
ok, I will do it in then my call back
|
bsr |
thanks Mark
|
bsr |
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 |
Nov 7 | 5:00 PM |
Mark M. | turned off guest access |