Skip to content Skip to sidebar Skip to footer

How To Save State Of Changed Imageview In Listview Row, After It Has Disappeared From Screen?

I have designed an application with a list-view in which I can change the colors of list items, here is a link to a screen from the application: The colors are changed by changing

Solution 1:

You should re-use the already created view.Some thing like this:

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if(convertView == null){
        //CREATE NEW HOLDER
        holder = new ViewHolder();
        // Layout XML
        int layoutFile = R.layout.adapter_layout;
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(layoutFile, null);
        convertView.setTag(holder);
        holder.tvName= (TextView)convertView.findViewById(R.id.tvName);

              /// SET DE VALUES TO THE VIEW HERE, INCLUDING THE
              /// ONCLICK TO THE VIEW
    Users u = arrayUser.get(position);

    holder.tvName.setText(u.getName());


    }
    else
        holder= (ViewHolder)convertView.getTag();
    return convertView;
}

static class ViewHolder{
    TextView tvName;
}   

Post a Comment for "How To Save State Of Changed Imageview In Listview Row, After It Has Disappeared From Screen?"