You are currently viewing the BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
With the ToDo List example, I would like to be able to set the focus to a particular item in the list, by code. For example I want to set the first item as highlighted automatically at the beginning, under program control. I have tried everything I can think off but not successful yet. Can anyone help please?
Further to my problem, I have successfully used
" myListView.setSelection0); " to position the place in the array list correctly.
That is part of my problem solved. The remaining part of the problem is that I have been unable to turn on the highlight at this position.
When I press the down key on the dpad the highlight turns on at the position I have set as outlined above. But when I try to use
" myListView.getSelectedItemPosition() " without manually highlighting the position first, the app crashes. That is why I want to highlight
an item by program control, to prevent such a crash. Thanks for your help so far. Is there any way to turn on the selection highlight?