Office Hours — Today, March 20

Thursday, March 15

Mar 20
7:15 PM
Mark M.
has entered the room
7:20 PM
Mark M.
turned on guest access
7:30 PM
Ron T.
has entered the room
Mark M.
howdy, Ron!
how can I help you today?
Ron T.
Evening Mark. I have a quick question(s) about WebView...
David O.
has entered the room
David O.
Hello
Mark M.
Ron: go ahead
(BTW, howdy, David!)
Ron T.
I've build a successful WebView app including the webviewclient using the loadURL method
David O.
Howdy Mark
Ron T.
I'm trying to use the loaddatawithbaseurl method
I notice that the onReceived event does NOT fire on it if there is no connectivity to the URL, Is this normal?
Mark M.
onReceived?
do you mean onReceivedError()?
Ron T.
Oops, onReceivedError correct!
Mark M.
in that case, that can be normal
the URL supplied to loadDataWithBaseURL() is used for relative URLs in the HTML being loaded
Ron T.
Yes, we figure it is trying to load down css.
Mark M.
so, you won't get onReceivedError() for the HTML you are loading, itself
Ron T.
If there is no connectivity to the URL and we can't get the css, we want the error taken...
Mark M.
you're saying that you are not getting onReceivedError() for your CSS?
7:35 PM
Ron T.
What it does is display the HTML I've got directly over the background which looks bad.
Mark M.
hmmmm
the docs for onReceivedError() refer to "the main resource"
perhaps that is not used for images, CSS, etc.
I have not used onReceivedError() personally
Ron T.
yes, if you use the loadurl, it takes the error and lets us display a nice message...
Mark M.
:: shrug ::
Ron T.
We have previously read the HTML on async and have buffered it.
I'll play with it more but it would be nice to have a flag to let us error if we can't load resources!
Mark M.
my best guess is that onReceivedError() is for pages, not other resources (images, CSS, etc.), but that is just a guess
sorry I couldn't be of more help on that one
Ron T.
Okay, just wanted to make sure I wasn't missing something. Over and out for now! Thanks!
Ron T.
has left the room
Mark M.
David: do you have question?
David O.
I have a few...
Mark M.
go right ahead!
David O.
Are you familiar with the ActionBarSherlock library?
Mark M.
somewhat
I've used it
but I have not used every feature
David O.
I'm having problems setting it up and using ti
7:40 PM
David O.
the 3.5.1 version seems to work, but it is missing most of its themes
when I try to use the sherlock themes from the 4.0 version eclipse crashes with a stackoverflow exception
and crashes when it opens unless I remove the theme
Mark M.
*Eclipse* crashes?
David O.
yes
Mark M.
I haven't seen that
David O.
i'm using windows
Mark M.
:: insert Windows joke here ::
:-)
David O.
me
i'm joke's on me
Mark M.
I am running Eclipse Indigo on Linux
I have not seen Eclipse crash with a stack overflow
David O.
i tried seeting up ubuntu on my latop, but I can't because I have an Nvidia card with Optimus technology
Mark M.
so do I
David O.
I'm going to make the switch eventually
i couldn't get the dual monitors working
I went through a process where you had to install the propreitary driver and uninstall the linux driver
that also crashed...i eventually gave up
but linux is much better
I'll stick to course material thought :)
and watch the typos....
Mark M.
anyway, I don't know what to tell you about an ABS-triggered Eclipse crash
David O.
I posted something on the ABS users group
Mark M.
are you on the latest Android tools release?
David O.
no
what it is 16?
Mark M.
hold on
yes, 16
7:45 PM
Mark M.
17 should be released fairly soon
David O.
then I guess I am
Mark M.
OK, so that's not it
David O.
Here's a different question
I think the problem is with referencing the ABS theme's
they don't seem to be with the library
if you actually look in the library there is no res file
Mark M.
the themes are definitely with the library
David O.
there is abs_styles
let me try something
Mark M.
um, there definitely is a res/ directory in the ABS library project
David O.
yes
Mark M.
at least, in the one I downloaded
David O.
you are correct..
i had one that I had imported improperly...I fixed that
the ABS themes are actually showing up in the graphical editor theme picker
should I be picking @abs_style/Theme.Sherlock.?
Mark M.
I have @style/Theme.Sherlock
@abs_style should fail to compile
David O.
Also, is it necessary to use a Sherlock theme...their documentation says that you need one on each activity using an ActionBar
7:50 PM
David O.
but it seems to work in 3.0 and up devices without a regular theme
Mark M.
I believe you need to use one of Jake's themes, if not directly then as the parent of your own custom theme
David O.
i've been extending his theme when I'm using it
Mark M.
that should be fine
David O.
Ok
I have a differnt question
I'm trying to create a 'menu' and 'submenu' panel using two gridviews
the first gridview acts as a filter, when you click on a ImageButton it drops down another gridview with menu options
do you follow?
Mark M.
so far
David O.
I am able to animate a 'slide_down' using a translate_animation
but I can't seem to get a 'slide_up' animation to work
7:55 PM
David O.
I used the same code...and just reversed the fromY and toY parameters
Mark M.
what was the effect?
David O.
the close animation doesn't work
Mark M.
define "doesn't work"
David O.
i'm calling setVisibility(GridView.GONE) right afterwards though
Here is the relevant code:
hold on
...also as a side note I'm having some trouble translating the animation into an anim.xml file
Mark M.
define "doesn't work"
David O.
doesn't work means that there is no animation
the submenu dissapears without sliding back up
i can't open the workspace with the project because when eclipse crashed it seems to have taken the workspace with it!
eclipse is saying that my workspace is in use
Mark M.
close the Eclipse you just opened, then use Task Manager to see if you have other copies of eclipse.exe floating around
David O.
i tried that...
one more time...
8:00 PM
David O.
i don't know
i closed all eclipse & adb processes it still not working
Mark M.
it might take a reboot, if Windows is holding some locks yet on the files
David O.
usually I have to restart my computer to fix this
Mark M.
regardless, I do not know why you would have a problem with what you described, unless animating something scrollable is somehow different
I have only animated non-scrollable items (buttons, LinearLayouts of misc widgets, etc.)
David O.
The gridviews don't have scrollbars
okay
Mark M.
compare your code with my SlidingPanel demos from _The Busy Coder's Guide to Advanced Android Development_ and see if you see any notable differences
David O.
I'd like to translate the animation into an anim.xml file and then load it using the AnimUtils.LoadLayoutAnimation
Mark M.
I seem to recall that TranslateAnimation in XML is funky
David O.
Can I copy and paste code into the chat?
Mark M.
sure
David O.
it's missing parameters
i can tell you that
8:05 PM
David O.
you can't set what the animation is relative to, programmatically you can set whether the animation is relative to the parent or to 'itself'...whatever that means
Mark M.
right
I've only ever used it on one (proprietary) project, and I recall it took me a while to figure out the right values to use
David O.
View paste
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<set android:interpolator="@android:anim/linear_interpolator" android:id="@+id/slide_down">
<translate android:fromXDelta="0.0" android:toXDelta="0.0" android:fromYDelta="0" android:toYDelta="100%p"/>
</set>
<!-- <layoutAnimation -->
<!-- android:delay="10%" -->
<!-- android:animation="@anim/slide_down" /> -->
</resources>
hmm..is it better to use the android animations?
Mark M.
what do you mean by "the android animations"?
David O.
the one's in the sdk
Mark M.
well, there's nothing wrong with those, if they happen to meet your needs
David O.
there are animations in the sdk resource folder
Mark M.
they might not be truly in the SDK in terms of android.R.anim references
David O.
either way I would run into the same problem with this particular case
Mark M.
you might need to copy them into your project
David O.
I'll make sure to do that
from what I've read online, you have to define a layoutAnimation in a layoutAnimation tag, and have it reference a translate animation
then you load the layoutAnimation and it returns a LayoutAnimationController...
Mark M.
I have not used layoutAnimation
David O.
but my android:id tags are not showing us references
should I stick to material from the books?
I'm fine with that
Mark M.
it's more that I can't help you with things I don't know :-)
8:10 PM
David O.
cool
8:10 PM
Mark M.
animations on the whole are not my strong suit
David O.
not mine either...
they are a bit tricky
i have a few quesitons about fragments
Mark M.
ok
David O.
I read throught your notes on the FeedsReader project
I'm unclear on exactly what the relationship is between the fragment stack and activity they are attached to
if an activity is actually destroyed, what happens to the fragmetns attached to it?
Mark M.
they are garbage collected
just as their views are
fragments do not live outside their activity
David O.
ok
what if you add the fragment to the backstack?
Mark M.
that simply means a BACK press will first reverse the FragmentTransaction
another BACK press would finish() the activity (if there are no other transactions)
David O.
oh okay
Mark M.
if the activity goes away for other reasons (e.g., you call finish()), the fragments still go away
David O.
okay
i tried replacing a fragment in a linear layout
and it didn't work
the original fragment wasn't replaced
Mark M.
define "didn't work"
you used replace() in a FragmentTransaction?
David O.
is
yes
8:15 PM
Mark M.
and the original fragment was also put there by a FragmentTransaction?
David O.
when i chagned the layout to a relative layout it worked
no
the original fragment in the layout.xml file
Mark M.
I have not tried replacing a static fragment (i.e., <fragment>) via a transaction
David O.
I got it using getFragmentById
Mark M.
I would not be surprised if there are issues there
David O.
okay
I'm also having some issues creating custom views
I don't undrestand what the View.MeasureSpec object does
and how it works
are you familiar with it?
Mark M.
I have only created composite custom views (e.g., ColorMixer)
I have not created one that needed to worry about onMeasure() and such
so I have no experience with View.MeasureSpec
David O.
ok
I had an issue with a cursor adapter...
I had a database that was able to return values into an array
but when I used a cursor adapter I got an ArrayIndexOutOfBounds exception
because the query wasn't returning anything
the cursor just had the database name so it should've translated into SELECT * FROM LINKS
8:20 PM
David O.
(I checked in the debugger, and this was correct)
Mark M.
you should not get an ArrayIndexOutOfBounds exception for a Cursor with no rows
as that is a perfectly normal occurrence
CursorAdapter surely handles that
David O.
hmm...
can I email you more information?
Mark M.
if you wish to go outside the chat, you are better served using StackOverflow
David O.
okay
Mark M.
looking at the source code, I don't see where CursorAdapter even has an array that might trigger such an exception
you sure this isn't due to a bad column index?
David O.
it could be
to be honest it's been a week or two since I've looked at it
Mark M.
hmmm... looking at more source code, that doesn't seem likely either
anyway, I am not sure where you would get an ArrayIndexOutOfBoundsException related to a Cursor and CursorAdapter
David O.
do you have anything on CursorAdapters in your books?
Mark M.
yes, in a few places
the chapter on databases in _The Busy Coder's Guide to Android Development_
David O.
Ok cool
Mark M.
the chapter on loaders in _The Busy Coder's Guide to Advanced Android Development_
and probably a few other places as well
8:25 PM
David O.
Are loaders preferable to cursors?
Mark M.
Loaders are a means of querying the database in the background
to retrieve a Cursor
Loaders do not replace Cursors -- in effect, they create them
David O.
ok
so they are on a seperate thread?
Mark M.
yes
usually, the loader uses an AsyncTask
David O.
I am having some general problems controlling and assinging focus to elements ina view
for example
i have a listview with buttons on it
it seems the button steals the focus from the listitem
Mark M.
yes
David O.
so if when you click on he listitem nothing happens
what methods/parameters do you want to look at to assign/reassing focus between views and their children?
Mark M.
well, specifically for your ListView scenario, I seem to recall that android:focusableInTouchMode is part of the solution
David O.
okay
I'll look into that
Mark M.
personally, I don't like lists that use focusable widgets (Buttons, EditTexts, etc.), so I avoid the pattern
in general, there are lots of focus-related methods (e.g., requestFocus()) and attributes (e.g., android:nextFocusDown) for managing the focus
8:30 PM
David O.
ok
Mark M.
that's a wrap for today's chat
David O.
Mark, I need to go now
Mark M.
next chat is Friday, 10am Eastern
David O.
and so do you
Mark M.
have a pleasant day!
David O.
thanks, you too
David O.
has left the room
Mark M.
turned off guest access

Thursday, March 15

 

Office Hours

People in this transcript

  • David Ozersky
  • Mark Murphy
  • Ron Thomas