Oct 23 | 3:55 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Oct 23 | 4:00 PM |
bsr | has entered the room |
Mark M. |
howdy, bsr!
|
Mark M. |
how can I help you today?
|
bsr |
Hi mark.
|
bsr |
We chat y'day night, and been struggling after a bit to make my list view selectable
|
bsr |
I saw some explanation in the book
|
bsr |
page 648
|
bsr |
But, your code uses listeners.. etc. But I was originally following the API demo
|
bsr |
I couldn't make selection state work with custom adapter
|
bsr |
and custom view
|
bsr |
is that the reason you use listeners, as you need to pass the state through parent activity
|
bsr |
not sure
|
Mark M. |
by "selection state", do you mean the highlight
that appears when the user clicks on the row (briefly) or selects a row
with the D-pad?
|
bsr |
exactly
|
bsr |
well, I have an android tablet
|
Mark M. |
the selection state has nothing to do with listeners
|
Mark M. |
the selection state is determined by the background of your rows
|
bsr |
so, if I click with my finger, it briefly highlights the row, and details get updated
|
Oct 23 | 4:05 PM |
Mark M. |
when you say "custom view", what do you mean?
|
bsr |
sorry, I was trying to look up the exact name
|
bsr |
but, it is in Android namespace with _select_ .. 1
|
B3hrooz | has entered the room |
bsr |
It was used in API demo , list view layout example
|
Mark M. |
bsr: I am sorry, but I do not know what you are referring to
|
B3hrooz |
Hi Mark
|
bsr |
please take qn from B3hrooz
|
Mark M. |
(howdy, B3hrooz!)
|
bsr |
I will look it up
|
Mark M. |
bsr: OK
|
Mark M. |
b3hrooz: do you have a question?
|
B3hrooz |
yes absolutely
|
B3hrooz |
I couldn't find much related material in the book
|
B3hrooz |
so I thought I would ask you directly
|
B3hrooz |
Do you happen to know much about voice recognition API?
|
Oct 23 | 4:10 PM |
Mark M. |
sorry, I have not played with either text-to-speech or speech recognition much yet
|
Mark M. |
it is on my list for 2013
|
B3hrooz |
awesome
|
B3hrooz |
in that case, many thanks for your great book, it's been a great resource for me so far
|
Mark M. |
you are very welcome, and thanks for the kind words!
|
B3hrooz |
Have a great day :)
|
Mark M. |
you too!
|
B3hrooz | has left the room |
Mark M. |
bsr: back to you!
|
bsr |
Mark, I was originally using android.R.layout.simple_list_item_1
|
bsr |
which handled the selection correctly
|
Mark M. |
and that should have worked fine
|
bsr |
then I followed the book to have custom adapter and view for each row
|
bsr |
then, the selection works as the content updates
|
bsr |
but, the color of row become normal after that
|
Mark M. |
I am not sure what you mean by those last two entries
|
bsr |
it is a list - master , 2 pane view
|
bsr |
when I select on the left (list), the details updates
|
bsr |
hence the selection works
|
bsr |
but the list focus/color of the selected item
|
Mark M. |
typically, for master-detail, you use the "activated" style, to keep a highlight on the row after the user taps
|
Mark M. |
you will see "activated" introduced in the Large Screens chapter, in the EU4You sample app
|
Oct 23 | 4:15 PM |
Mark M. |
though full details are in the Advanced ListViews chapter
|
Mark M. |
in the "Choice Modes and the Activated Style" section
|
bsr |
I know, it is hard for you to help without code. I will make a test case if I couldn't figure this out, and post in SO
|
Mark M. |
OK
|
bsr |
thanks Mark, that's all.
|
bsr |
have a good day
|
Mark M. |
you too!
|
bsr | has left the room |
Oct 23 | 4:20 PM |
bsr | has entered the room |
Mark M. |
hello again!
|
bsr |
:-)
|
bsr |
View paste
|
bsr |
I was wondering the significance of R.id.name
|
bsr |
as I doubt whether that field decides the selection in the list view
|
Mark M. |
that is the ID of the TextView inside the row layout that ArrayAdapter (the superclass of CountryAdapter) should manage itself
|
Oct 23 | 4:25 PM |
bsr |
so, if I load my data dynamically from a json array, each row will have a unique id
|
bsr |
because I saw you define it in resource like
|
bsr |
View paste
|
bsr |
so, it creates one view for each item in countries list?
|
Mark M. |
not really
|
Mark M. |
ListView and ArrayAdapter recycle rows that scroll off the screen
|
bsr |
I remember the ViewHolder patter :-)
|
Mark M. |
only as many rows as is needed to fill the ListView (and perhaps 1-2 others) will be created
|
bsr |
pattern :-)
|
bsr |
ok
|
bsr |
so, I can just use any unique id (int id from my json object) instead of defining it in resource file
|
Mark M. |
sure
|
Oct 23 | 4:30 PM |
Mark M. |
you do not even really need a unique ID
|
Mark M. |
for example, I do not use the string resource IDs for anything other than getting at the strings
|
Mark M. |
in the sample you were pasting from earlier in this chat (EU4You)
|
bsr |
I been studying that example.
|
bsr |
can u please comment on why you used the interface
to define the call back, or whether passing the selection through
intent would work aswell
|
bsr |
in the same example
|
Mark M. |
I have no idea where you think an Intent would be involved in the handling of the ListView click event
|
Mark M. |
I elected to use an interface to demonstrate using an interface
|
Mark M. |
you might need that if there were two possible activities that held the fragment
|
Mark M. |
in this case, there can only be one activity holding the CountriesFragment
|
Mark M. |
so I could have cast getActivity() to be EU4You instead of CountryListener
|
bsr |
I though the purpose was to pass the current selection
|
Oct 23 | 4:35 PM |
bsr |
which not sure could pass along with Bundle
|
bsr |
thanks for explaining
|
Mark M. |
you need to tell the hosting activity which Country was clicked upon
|
Mark M. |
that's what the onListItemClick() method of the fragment does
|
Mark M. |
then the activity can determine whether it can display the details itself or needs to start up some other activity to do that
|
bsr |
thanks Mark . I will catch you next week :-)
|
bsr |
thanks again for the help, and patience :-)
|
Mark M. |
you are very welcome
|
bsr | has left the room |
Oct 23 | 4:55 PM |
Mark M. | turned off guest access |