I have a application that has an activity that shows message logs. The thing is the user must to be able to select some messages and then delete them as you can do when you want to remove some sms messages.
Which is the best way of doing that? Adding more details:
Here is a capture with the messages only.

Here is a capture with the selection layout.

I want to know how they do it to show the CheckBoxes. Did they use two layouts?
I doubt they use two layouts files. As the rows are very similar it very easy to switch from the layout that doesn’t have the
CheckBoxto the layout that does have theCheckBoxjust by changing the visiblity. A way to do it would be to have a flag in your adapter that indicates the presence of theCheckBoxin the rows and update theCheckBoxvisibility based on that flag:Then when it’s time to show those
CheckBoxes(on aButtonclick, menu click etc) you just have to set thecheckStatusflag to the desired value(trueforCheckBoxespresent,falseotherwise) and callnotifyDataSetChanged()on your adapter.Of course you could use two layouts, one that contains the
CheckBoxand one that doesn’t have it. But, generally, you would use two layouts in aListViewwhen the two layouts are very(or substantial) different(which is not your case). To implement the two layouts you would have to use the methodsgetItemViewTypeandgetViewTypeCount.Then in your
getViewmethod:Of course when it’s time to show the
CheckBoxesyou would have to set thecheckStatusflag again and callnotifyDataSetChanged()on your adapter.