Sep 4 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Sep 4 | 4:00 PM |
Prasanna | has entered the room |
Mark M. |
howdy, Prasanna!
|
Prasanna |
Hi Mark
|
Mark M. |
how can I help you today?
|
Prasanna |
I am using a simplecursor adapter with a list
view. I am using a custom row that has 3 textfields and a button to
populate the list. The 3 text fields are populated from the database.
When you click on the button I want to show and alert with detail
information which I want obtain from the relevant row in the database.
How do I set a onClickListener to the button in a way that I am able to
get access to the relevant row in the cursor?
|
Mark M. |
personally, I *really* don
|
Mark M. |
er
|
Mark M. |
personally, I *really* don't like ListView holding rows that are this interactive
|
Mark M. |
if there are only a few rows (say, less than 50), use a vertical LinearLayout in a ScrollView
|
Prasanna |
there will be more than 50 rows
|
Mark M. |
in which case, this should not be in one ListView, IMHO
|
Mark M. |
be that as it may
|
Sep 4 | 4:05 PM |
Mark M. | |
Mark M. |
that sample project shows how to attach listeners
to widgets in a ListView row (in this case, a RatingBar) with knowledge
of what position they are associated with
|
Prasanna |
ok
|
Prasanna |
so, if I am not to use a ListView for this, how would I proceed?
|
Mark M. |
having a ListView is fine, but the data entry should not be in-line in the ListView, but in a detail fragment/activity/whateer
|
Mark M. |
er, whatever
|
Mark M. |
(BTW, the sample app I mentioned is described on pages 733-737 of Version 4.1 of the book)
|
Prasanna |
ok thanks Mark.
|
Prasanna |
There is not going to be data entry for this implementation in the ListView.
|
Mark M. |
you said that there are "3 text fields" in the rows
|
Prasanna |
oh, meant textview
|
Prasanna |
sorry
|
Mark M. |
if you really mean three TextViews, then I don't
know why you need the button -- just respond to taps on the rows
themselves, the way ListViews normally work
|
Sep 4 | 4:10 PM |
Prasanna |
Good point. I think I will respond to the taps on the row. The button was what the client had in mind ...
|
Prasanna |
Do you have an example in your book on respond to the row tap
|
Mark M. |
if you are using ListActivity or ListFragment, just override onListItemClick()
|
Mark M. |
lots of samples show that
|
Prasanna |
ok
|
Mark M. | |
Mark M. | |
Mark M. | |
Mark M. |
if not, you will need to call setOnItemClickListener() on the ListView, supplying an OnItemClickListener implementation
|
Prasanna |
got it
|
Prasanna |
Another question ...
|
Prasanna |
I have a list view that has 3 columns that are
populated using a cursor adapter. I want to provide a search box for
the user to serch the text in any of the 3 columns. Any hints on how I
would go about doign this
|
Mark M. |
which part of "this" are you concerned about?
|
Prasanna |
is there any component, api etc that I can use for search the data in a sqlite database
|
Sep 4 | 4:15 PM |
Mark M. |
um, well you search a SQLite database by executing a query, via rawQuery() or kin
|
Mark M. |
that's how you got your Cursor for your CursorAdapter in the first place, presumably
|
Prasanna |
yes
|
Mark M. |
so, if you want to search the contents of the database, create and execute another query
|
Prasanna |
ok
|
Prasanna |
so just bring up an alert to collect the text to search and execute a query and show the results I guess ...
|
Mark M. |
you can bring up the standard search field if you prefer, vs. a dialog
|
Prasanna |
how do I do this?
|
Mark M. |
see Searching with SearchManager, starting on page 1247, of Version 4.1 of the book :-)
|
Prasanna |
thanks Mark
|
Sep 4 | 4:20 PM |
Prasanna |
I will refer to the book, thanks directing me.
|
Prasanna |
Ok Mark. Heading out. Hope you have a great rest of the day.
|
Mark M. |
you too!
|
Prasanna | has left the room |
Prasanna | has entered the room |
Prasanna |
Actually I more question
|
Mark M. |
hi again! :-)
|
Prasanna |
On the same ListView, I want to implement sorting on a few columns ...
|
Prasanna |
I am thinking of having buttons on top of the relevant columns, so that when you press on one of these buttons ...
|
Prasanna |
I will execute the query again doing the relevant sort and populating the ListView again ...
|
Prasanna |
Am I doing the right thing here?
|
Mark M. |
in terms of re-querying the database, that is certainly simplest
|
Mark M. |
if speed is an issue, you could look to do more stuff in-memory to do the sort on the original query result
|
Sep 4 | 4:25 PM |
Mark M. |
in terms of the buttons-on-top-of-the-columns, I don't see that UI approach taken often
|
Mark M. |
sort is either triggered by an options menu/action bar item, or perhaps a Spinner in the UI itself
|
Mark M. |
basically, so a single errant tap doesn't lose the user's place, presumably
|
Prasanna |
yes, makes sense
|
Prasanna |
do you have an example in your book similar to re-querying the database and showing results again?
|
Mark M. |
well, the search sample in the chapter I mentioned shows displaying search results
|
Mark M. |
it's not in a database, though
|
Mark M. |
I do not have a sample that shows implementing search with database-backed content, sorry
|
Prasanna |
do you have a an example that does just queries the database again and shows the results in a ListView
|
Mark M. |
not in terms of "again"
|
Mark M. |
I have samples that show querying a database, but only on startup, not based on user input
|
Sep 4 | 4:30 PM |
Mark M. |
in the case of sorting, you'd just use swapCursor() or changeCursor() on your CursorAdapter to load in new results
|
Mark M. |
actually, my database samples do show re-loading the database contents after rows are added
|
Mark M. | |
Prasanna |
great
|
crazykid | has entered the room |
Mark M. |
howdy, crazykid!
|
Prasanna |
thanks Mark.
|
crazykid |
hi Mark
|
Prasanna | has left the room |
Mark M. |
Prasanna: sure
|
Mark M. |
crazykid: how can I help you today?
|
crazykid |
i've decided that my main navigation is better
suited for tabhost - I may utilize the view pager inside one of the
tab's for sub-navigation, but the view pager doesn't really fit the
overall feel we are going for
|
KBZoiD | has entered the room |
Mark M. |
crazykid: sorry, I need a bit more context as to what you are talking about
|
Mark M. |
(BTW, howdy, um, KBZoiD!)
|
KBZoiD |
hello everyone
|
KBZoiD |
hi Mark :)
|
Sep 4 | 4:35 PM |
crazykid |
right now i am following the tutorial on tabhost
and tabwidget...its set up in a way to load views. is it wrong to have
the tabs load activities instead?
|
crazykid |
hi KB
|
Mark M. |
activities-in-tabs is officially deprecated
|
crazykid |
sorry mark I was referring to our convo last week regarding the different methods for navigation in my current project
|
crazykid |
mind if i upload an image?
|
Mark M. |
I apologize for not necessarily remembering everything from week to week in the chats
|
Mark M. |
heck, some days I barely remember what I had for breakfast :-)
|
Mark M. |
yes, feel free to upload an image
|
crazykid |
i know my fault
|
crazykid | |
Mark M. |
FWIW, bottom tabs are frowned upon: http://developer.android.com/design/patter…
|
crazykid |
so in this app, the navigation at the bottom loads
a new activity in the main area..I assume its a activity because the
back button returns you to the previous view
|
Mark M. |
the BACK button behavior has no bearing here
|
crazykid |
hrmm, ok how about this ::uploading another file::
|
Mark M. |
activities-in-tabs would exit the whole tab set on a BACK press too
|
crazykid | |
Mark M. |
they have overridden onBackPressed() to have alternative behavior
|
crazykid |
oh ok
|
Mark M. |
overriding onBackPressed() does not have much to do with how the contents are rendered
|
Mark M. |
so that could have been views-in-tabs, activities-in-tabs, or something else entirely
|
Sep 4 | 4:40 PM |
crazykid |
ok
|
Mark M. |
if the classic TabHost gives you your desired
look, that's fine, though I'd still look into how you can re-implement
the TabWidget style in the form of an indicator to go with ViewPager
|
Mark M. |
swiping between "tabs" is getting fairly popular
|
Mark M. |
to the point where users may start expecting it
|
crazykid |
roger
|
crazykid |
so i can set up the "global" tabbed navigation in the viewpager?
|
crazykid |
i mean the look and feel
|
Mark M. |
I hesitate a bit on the word "in"
|
Mark M. |
the content is "in" the ViewPager
|
Mark M. |
the tabs are an indicator associated with the ViewPager
|
Mark M. |
depending on implementation, that indicator strip may be a child or sibling of the ViewPager
|
Mark M. |
let me take a question from KBZoiD, then circle back to you for more follow-up
|
Mark M. |
KBZoiD: do you have a question?
|
crazykid |
sounds good
|
Sep 4 | 4:45 PM |
KBZoiD |
no no, no problem :D im just starting reading your book and reading other people's questions is quite useful for me :)
|
KBZoiD |
thank you anyway! i understand it all so far :P
|
Mark M. |
oh, OK
|
Mark M. |
crazykid: back to you, then
|
crazykid |
yea so I guess I just need to get my head around viewpager a little better
|
Mark M. |
there's a whole chapter on it in the book :-)
|
Mark M. |
the tutorials also use it, FWIW
|
KBZoiD |
gotta go now. nice to meet you guys and thank you for the book Mark
|
KBZoiD |
catch you guys soon
|
KBZoiD |
bye
|
crazykid |
haha, i know and i had no issues while reading /
doing the examples..now when applying it to my app and navigation issue
I'm having a tough time figuring out how to incorporate
|
crazykid |
bye KB
|
Sep 4 | 4:50 PM |
crazykid |
but I'll just re-read :)
|
crazykid |
one more thing
|
crazykid |
so any resource I see (stackoverflow, etc) loading activities via tabs I should avoid, correct?
|
Mark M. |
again, that technique is deprecated
|
Mark M. |
it probably still works as well as it ever did, but I would go in other directions
|
crazykid |
ok, how about fragments in tabs?
|
Mark M. |
that's perfectly reasonable and is the preferred alternative to activities-in-tabs
|
crazykid |
ok cool, thanks mark
|
Sep 4 | 4:55 PM |
crazykid |
adios
|
Mark M. |
have a pleasant day, both of you!
|
crazykid | has left the room |
Sep 4 | 5:00 PM |
KBZoiD | has left the room |
Mark M. |
that is a wrap for today's chat
|
Mark M. |
the next one is Thursday, 10am Eastern
|
Mark M. | turned off guest access |