modify particular list item - android

i want to edit the particular list item after the,all data loaded into listview using base adapter.
we can achieve this by reloading the listview with edited value,but i want to do this without reloading the entire listview data.bcoz the data is huge

If I understand ur question properly, When the list item is clicked, u need to make it editable.
Keep two views, one for editing ( EditText ) another TextView for showing.
On Click of list item or TextViw, make TextView Gone and make EditText visible.
When the editing done ( may be other list item click or Done button of keyboard ) copy the content of EditText to TextView and make EditText Gone and TextView visible.
I have done the same for some of the requirement I had in my pet project

Related

Custom Listview with Text and two Images

I am new to Android Development and I am making an application in which I have an EditText and below EditText there is submit Button.
I want that when I write something in EditText and then click submit, the Edittext value will show in Listview with pre defined two Images i.e. their is EditText value in listview and on the right of it two Images also added with that Submit button. These images are Delete and Edit Images so that whenever i click on delete it delete that item and whenever i click on Edit image the EditText value will be ready for editing.
I know that this will be done by getView method and a holder but i could not find any best example for that.
Can anyone provide me the best example for holder and custom listview regarding my application?

issue on check boxes inside listview's every child item in android

I am working on check boxes in android, I had a listview with child having one checkbox, image, textviews and their respective onclick events. I blocked at selecting only one checkbox in the entire listview child at a time. if user wants to select other item then previously selected checkbox need to be unchecked in the listview. Please suggest me . thanks in advance.

Which is better way to implement edit - listview with edittext or table layout with edittext

Need to implement edit in runtime. Which one is the best way to achieve it.
Edittext in Listview or dynamic table layout(inflating row xml) with edittext
Update:
My listview contains 7-8 view(Text view) in a list item. On click edit button using view switcher changed textviews to edit text. To get the entered value in edittext listening onfocuschanged. It brings very slow performance. Any better way to achieve it?
Update:
If my listview have 100 list items. Each item having 7-8 edittext. Need to listen all the edittext focuschange. My app hangs. What should i do?
EditText within ListView can cause you great grief down the lane given that views are recycled in listview.
Say you have tapped on the second row in a listview where all item rows contain a edittext and you have set adjustResize in your AndroidManifest.xml; after the soft keyboard pops up, the focus goes into the first view that can accept the focus which in this case will be the first edittext (row) of your listview. Yes, you can tap again on the desired edittext to regain focus. But it is an annoyance nevertheless. If you set adjustPan, then I have seen the the problem does not exist as such; if I recollect correctly, you cannot scroll down all the way to the end of your list. Again, another annoyance.
I'd suggest, you go with a ScrollView if the number of items in the list are less. I have been trying to solve this for the last couple of days - I ended up doing this - I replaced the edittext's with textview's in the listview; tapping on the textview would bring up a dialog fragment that contains the edittext.
Have you looked into the concept of a ViewHolder to keep a reference to the items of the listview? That should solve your multiple focus listener problems.

Clear the edit text in a custom list row

I have a custom list row which has two TextView and one EditText .
I want to clear the text typed in EditText of all the list rows on a Button click which is a reset button.
The Button is in an Activity
Can anyone suggest me a way I can achieve this.
Well your question is not clear at first, if you mean a system like listview or scroller when you say custom list row, then while on click of button do the following
Get all the child from the view
loop through each child, finding EditText inside each child view
Simply setText to empty.
I hope got your question right, else please put some code here.
You can use this to clear the editText
YourEditText.setText("");

how to keep check box selection in ListView

I have created a custom ListView.. every element of my ListView constructing from a layout.
My layout will have some TextViews and a ToggleButton. My ListView will have some 50 elemnts and my device screen can show 2 elements at a time.
Now if we select ToggleButton on a Item and scroll down my ListView , the selected item will be out of screen and when I come back to the previous selected item I am observinf that selection for that toggle button is gone.
I know that this is a normal behavior in android that It will construct the elements which is currently displaying.
But I want to keep that value.. Is there any way that we preserve selection. or can I tell ListView to donot construct every time.. memory is a not a issue for my application.
Please let me know if there's any good solution for this.
You could store the states of the checkbox in a map with the position as the key. So whenever the list reloads after scroll, it loads based on the hashmap state. You should write this logic in the getView()

Categories

Resources