To do check list in Android List view?
I am building a application with to do checklist in it. In this is want to have a simple list view but with editable Edit text in it. I am able to populate the list with the initial values. How ever when i enter text into the edit text, somewhere in between the getview gets called from the adapter and the list view refreshes itself开发者_JAVA百科. I tried a round about where i keep updating the data source as and when I am typing in the edit text. Now the value is saved even after refresh. But the problem is that I keep entering the text and in between the list refreshes and i loose the focus from the edit text. Please let me know how to deal with this issue. Thank you for any kind of help and advice.
Can do like This
ListView lw= (ListView) findViewById(R.id.ListView01);
lw.setAdapter( new ArrayAdapter<String>(this,android.R.layout.simple_list_item_checked ,value ) );
You're going to need to track the state of your list. I did this by extending the adapter and keeping a HashMap of all of the views in my adapter. In my ListView, in onSaveInstanceState, I would get my adapter and iterate all of the views - for each view, I'd call onSaveInstanceState and store the result in my adapter's hashmap. Then, during onRestoreInstanceState, I would iterate all of the views and invoke their onRestoreInstanceState method, passing them the state I'd saved.
This should result in solving both your data and your focus issue...
Good luck - happy coding.
B
精彩评论