android - Manupilate a single row in listview -
the problem
my way add view makes every fifth item add view when want 1 position have "mängd" row. why can edit listitems when visible on screen. child static @ 5 items though got 20 item.... there way item 1 have , not
position - firstvisibleposition
i think problem listview
my code not understandable @ time because of other things hope problem anyways.
this main question
it seems thing add position 0 happens 6 , 12 why listview wierd ? it's on swedish, got list view. every listview item has empty linearlayout add view when press down arrow button. problem every fifth item gets or can click on first 5.
i dont why make listview complicated. want able child in list without seening it!
code getview
public view getview (int position, view convertview, viewgroup parent){ if (convertview == null) { convertview = layoutinflater.from(getcontext()).inflate(r.layout.view_meal_item_editable, null); } convertview.setontouchlistener(new itemswipelistener(position, getresources().getdisplaymetrics().density)); convertview.setclickable(true); // lookup view data population textview food_item_name = (textview) convertview.findviewbyid(r.id.food_item_name); food_item_name.sethint("hello"); }
where add view
view view = searchresultlist.getadapter().getview(position, searchresultlist.getchildat(position - searchresultlist.getfirstvisibleposition()), searchresultlist); linearlayout extendedview = (linearlayout)view.findviewbyid(r.id.extended_food_information); view convertextendedview = layoutinflater.from(this).inflate(r.layout.change_amount_on_food_view, null); extendedview.addview(convertextendedview);
it's recommended use header view if stuff first element.
otherwise better if add view in getview()
method, like:
if(position==0){ // add view } else { // remove view if exist }
or can remove if condition: if (convertview == null)
, inflate new layout each time, solve problem not good list performance
Comments
Post a Comment