Jan 8 | 9:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Carlos V. | has entered the room |
Mark M. |
hello, Carlos!
|
Mark M. |
how can I help you today?
|
Carlos V. |
Hi Mark
|
Marcin | has entered the room |
Mark M. |
hello, Marcin!
|
Mark M. |
Carlos: do you have a question?
|
Jan 8 | 10:00 AM |
Carlos V. |
I'm working on a DateDialogFragment and I'm
struggling to restore the state of a "set date" when the edittext field
is clicked again
|
Ricardo P. | has entered the room |
Ron B. | has entered the room |
Carlos V. |
I'm using onSavedInstanceState to save the day/month/year and trying to use those values in onCreateDialog
|
Mark M. |
(BTW, hello Ricardo and Ron -- I will be with you shortly)
|
Ron B. |
Hello Mark
|
Ricardo P. |
Hello
|
Carlos V. |
Once a user selects a date (my EditText has an
onClick attribute) when the EditText is re-clicked the DateDialog is
re-set to today's date.
|
Carlos V. |
This is my code: https://bitbucket.org/cavega/datepickerdialogsa...
|
Eugene | has entered the room |
Carlos V. |
Can't seem to find why onCreateDialog always has a null bundle
|
Mark M. |
It will only have a non-null bundle on a configuration change or similar event, AFAIK
|
Mark M. |
(BTW, howdy, Eugene -- you are fifth in line -- I will be with you as soon as I can)
|
Carlos V. |
yeah, that's what I'm seeing.
|
Eugene |
Hello Mark and all. Please advice what is the best
way to work with sqlite on non rooted device? I need to check if my
data inserts to a table(s) correctly.
|
Mark M. |
Eugene: I will get to your question in turn
|
Eugene |
thank you
|
Carlos V. |
Is there a way to retain the object? Do I have to
send the calendar object to the activity? I'm doing everything from the
Fragment
|
Mark M. |
Carlos: you will need to supply your initial data to your DialogFragment by some other means
|
Carlos V. |
hmmm
|
Mark M. |
Carlos: you are not doing "everything from the Fragment", because your EditText is not in the fragment
|
Mark M. |
consider using the factory pattern and setArguments() on the Fragment to pass in initial data
|
Carlos V. |
That's right. I guess most of it :)
|
Mark M. |
I have not tried that with a DialogFragment, but I would imagine it would work
|
Jan 8 | 10:05 AM |
Mark M. |
so you'd have a static method on SelectDateFragment that takes a Calendar or something
|
Carlos V. |
I've done a similar approach in a master/detail logic. I'll give that a try here. Thanks!
|
Mark M. |
OK
|
Mark M. |
I will be back with you in a little while, after I have taken a question from everyone else
|
Mark M. |
Marcin: do you have a question?
|
Marcin |
Hi Mark, yes
|
Marcin |
I have sherlock actionbar with search.
|
Ron B. |
Hi Mark,
|
Marcin |
I dont have searchable activity.. in onCreateOptionsMenu I add setOnSuggestionListener
|
Marcin |
then create suggestions as simplecursorAdapter
|
Ron B. |
Sorry I was pre-typing, thought it wouldn't send :-)
|
Marcin |
and set them with setSuggestionsAdapter
|
Marcin |
it all works fine
|
Marcin |
however.. when i start typing in search box in action bar
|
Marcin |
it doesnt matter what i type.. as soon as i enter any two characters
|
Marcin |
list of all suggestions pops up
|
Marcin |
i would like it to be filtered, depending what i type
|
Mark M. |
I have not used SearchView, but from what I see of the API, that is not how it works
|
Mark M. |
you could try using an AutoCompleteTextView of your own
|
Mark M. |
since AutoCompleteTextView has the behavior that you describe
|
Jan 8 | 10:10 AM |
Mark M. |
another possibility is to register an OnQueryTextListener, and set a new CursorAdapter whenever the query text changes
|
Mark M. |
I have no idea how well that works
|
Mark M. |
of course, I also have no idea why setSuggestionsAdapter() needs a CursorAdapter, rather than just a regular ListAdapter
|
Marcin |
yes.. its strange
|
Mark M. |
hopefully, one of those two techniques will get you what you want
|
Marcin |
thanks for suggestions Mark, thats it from me
|
Mark M. |
OK
|
Mark M. |
Ricardo: do you have a question?
|
Ricardo P. |
yes I do
|
Ricardo P. |
it's somewhat long question (15 lines), but easy to answer (I hope)
|
Ricardo P. |
View paste
|
Mark M. |
I like easy questions :-)
|
Mark M. |
hmmmm...
|
Mark M. |
off the top of my head, I forget where I came up with that
|
Mark M. |
hold on one moment...
|
Ricardo P. |
ok
|
Mark M. |
if I had to guess, I probably based it on the diagram and material here: http://developer.android.com/guide/components/f...
|
Ricardo P. |
hmmmmm
|
Mark M. |
my belief is that the framework will invoke
onActivityCreated() after your onCreate() code has wrapped up, but
before the base implementation of onCreate() returns
|
Jan 8 | 10:15 AM |
Ricardo P. |
no
|
Ricardo P. |
I checked that yesterday
|
Ricardo P. |
in a configuration change, onActivityCreated() is called in the activity's onStart() method
|
Ricardo P. |
so that's why I am a little confused about this
|
Mark M. |
it's entirely possible the book is wrong then
|
Mark M. |
I will make a point to do some more investigation
|
Ricardo P. |
ok, so thread management though fragments is still a problem if this is not necessarily true
|
Mark M. |
well, it's more a question of what lifecycle methods have the guarantee
|
Mark M. |
for example, if you replace onActivityCreated() with onCreateView() in the passage you quoted, that I am more certain is correct
|
Ricardo P. |
well, I cheched that onAttach() is called in the activity's onCreate(), so I guess that in that case the guaranteee holds
|
Mark M. |
right
|
Mark M. |
so it's a matter of trying to determine what the
current behavior is, then my trying to wrangle some confirmation of
expectations out of Googlers
|
Mark M. |
like I said, I'll need to do some more investigation
|
Mark M. |
my apologies for possibly steering you down the wrong path with what's in there now
|
Ricardo P. |
ok, that would be wonderful, since this is a very
important part of the framework and there is obviously not much
documentation out there
|
Ricardo P. |
no worries
|
Ricardo P. |
thanks a lot
|
Ricardo P. |
I am done!: )
|
Mark M. |
Ron: your turn!
|
Ricardo P. | has left the room |
Ron B. |
Hi Mark, Hopefully another long liner, but easy.
I'm using Tabhost/Tabwidget to support Android 2.x devices. I have the
following code;
|
Ron B. |
View paste
(4 more lines)
|
Jan 8 | 10:20 AM |
Mark M. |
that's odd
|
Mark M. |
oh, wait
|
Mark M. |
hold on one moment...
|
Mark M. |
there are two setup() methods
|
Mark M. |
the one you are calling works if your tab contents are views
|
Mark M. |
the one the error message wants you to call takes a
LocalActivityManager as a second parameter, and is needed if you have
activities in tabs
|
Ron B. |
Thought it was something like that, per the example in your book...
|
Mark M. |
(which, BTW, has been deprecated for nearly two years)
|
Mark M. |
if you use TabActivity, you do not need the setup() call, as it does that for you
|
Mark M. |
assuming your activity that hosts this TabHost is really an ActivityGroup, call setup(this)
|
Ron B. |
I thought is was just the TabActivity that was deprecated. Is there a better was to support Android 2.x?
|
Mark M. |
it's more that ActivityGroup, and activities-in-activities, that was deprecated
|
Mark M. |
just about any other tab solution works on 2.x: views in a TabHost, action bar tabs, ViewPager with PagerTabStrip, ...
|
Mark M. |
let me take questions from the others, and I will be back with you in a few minutes
|
Mark M. |
Eugene: copy your database to external storage, and examine it there
|
Jan 8 | 10:25 AM |
Eugene |
I've just connected to db using adb (on emulator),
but it happened I don't have my talbe in there... .tables gives me
nothing, don't you know why it could be?
|
Carlos V. |
Mark, I have one more question regarding DialogFragments. Let me know when its my turn again.
|
Mark M. |
Eugene: bear in mind that the sqlite3 command will
quietly create an empty database if it cannot find one on the path that
you specified
|
Mark M. |
so, first, make sure that you gave it the proper path to your database on the emulator
|
Eugene |
oh, ok, thanks
|
Mark M. |
or, copy off the emulator (File Explorer or adb
pull) and examine it using a desktop SQLite tool, like the Firefox
extension that I use
|
Mark M. |
another approach would be to add test methods to your unit test suite that inspect the contents of the database
|
Eugene |
got it, thank you
|
Mark M. |
Carlos: do you have another question?
|
Jan 8 | 10:30 AM |
Carlos V. |
Yes. I read in the book about how the DateDialogFragment no longer has a cancel button.
|
Mark M. |
there is no DateDialogFragment in Android
|
Mark M. |
do you mean DatePickerDialog?
|
Carlos V. |
I use this app called "Tasks" that does show it, even on my phone with Android 4.2.
|
Carlos V. |
Oopps...meant DialogFragment for DatePicker :)
|
Mark M. |
you need to add a negative button listener
|
Carlos V. |
I read this long post on stackoverflow about a
work around for pressing the back button when the user wants to get out
of the Dialog.
|
Mark M. |
yes, I linked to that from the book
|
Carlos V. |
Does the negative button listener automatically adds the cancel button or do I have to extend the class?
|
Mark M. |
AFAIK, the negative button listener alone suffices
|
Mark M. |
bear in mind that you can also either fork
DatePickerDialog, or create your own AlertDialog with a DatePicker, so
you have complete direct control
|
Mark M. |
Marcin: do you have another question?
|
Carlos V. |
Yes, I was thinking of using AlertDialog and doing
that. I guess using AlertDialog is a little extra work but on the
upside it is more "future proof".
|
Mark M. |
Carlos: agreed
|
Jan 8 | 10:35 AM |
Carlos V. |
BTW, do you have a bitbucket account? Just
wondering in case in a future chat I need to show you a private source
file? Just wondering.
|
Mark M. |
no, I don't use bitbucket
|
Mark M. |
I'm a GitHub guy
|
Mark M. |
Ron: do you have another question?
|
Ron B. |
Thanks Mark, I stuck with TabHost/Tabwidget based on page 162 of Advanced Android:
|
Carlos V. |
Hehehe. Fair enough. I use bitbucket solely
because it has free private repos :) Thanks again for your feedback on
my questions. That is all for today!
|
Ron B. |
View paste
|
Ron B. |
I just tried ActionBar, it's not recognized in 2.x?
|
Mark M. |
Note that _The Busy Coder's Guide to Advanced
Android Development_ was retired a while ago, replaced by the omnibus
_The Busy Coder's Guide to Android Development_
|
Mark M. |
to use the action bar on Android 2.x, you need a backport, like ActionBarSherlock
|
Mark M. |
ActionBarSherlock is covered heavily in the omnibus
|
Mark M. |
so, in Version 4.5, the action bar (with
ActionBarSherlock) is covered in "Options Menus and the Action Bar", and
action bar tabs is covered in "Action Bar Navigation"
|
Ron B. |
Hmmm, or I can just add the LocalActivityManager parm to the addTab method call?
|
Jan 8 | 10:40 AM |
Mark M. |
if you mean the setup() call, yes
|
Ron B. |
So it's setup(LocalActivityManager ??)
|
Mark M. |
yes
|
Mark M. | |
Mark M. |
or http://goo.gl/L2sqh since that link did not work well
|
Ron B. |
OK, thanks!
|
Mark M. |
Eugene: do you have another question?
|
Mark M. |
OK, if anyone has any questions, chime in
|
Jan 8 | 10:45 AM |
Ron B. | has left the room |
Jan 8 | 10:50 AM |
Marcin | has left the room |
Eugene | has left the room |
Carlos V. | has left the room |
Jan 8 | 10:55 AM |
Mark M. | turned off guest access |