-1

I have ListView with customer Adapter,my listView rows should animate when i click Edit Button and show delete icon in each row.

All rows make animation and show delete icon, but first hidden item doesn't change until I scroll list down and i see it when animate.

how can I make all List items animate in the same time ?

I put animation code in CustomerAdapter Class in getView method.

Code:

public View getView(int position, View convertView, ViewGroup parent) {

    View view = convertView;
    ViewHolder holder;

    if(convertView==null){

        view = inflater.inflate(R.layout.layout,parent,false);

        holder = new ViewHolder();
        holder.title = (TextView) vi.findViewById(R.id._title_textview);          

        holder.content=(LinearLayout)vi.findViewById(R.id.content_layout);

        holder.deleteIcon=(LinearLayout)vi.findViewById(R.id.delete_layout);

        holder.img=(ImageView)vi.findViewById(R.id._main_img);

        view.setTag( holder );
    }
    else
        holder=(ViewHolder)vi.getTag();


    if(MainActivity.click_edit_btn)
        {
            animation_right_to_left(holder.content_layout);
            holder.deleteIcon.setVisibility(View.VISIBLE);
        }

    if(MainActivity.click_done_btn)
        {
            animation_left_to_right(holder.content_layout);
            holder.deleteIcon.setVisibility(View.GONE);
        }

    if(data.size()<=0)
        holder.title.setText("No Data");
    else
    {
        tempValues=null;
        tempValues = ( ListItemModel ) data.get( position );

        holder.title.setText( tempValues.getTitle() );
        holder.type.setText( tempValues.getType() );

    }
    return view;
}

Activity Code:

public class MainActivity extends Activity {
. . . . .

    adapter = new CustomerAdapter( CustomListView, listData ,res );

    list.setAdapter( adapter );

    edit_layout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            click_edit_btn = true;
            click_done_btn = false;

            adapter.notifydatasetchanged();

        }
    });

    delete_done_layout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            click_edit_btn = false;
            click_done_btn = true;

            adapter.notifydatasetchanged();
        }
    });

    }
Amjad
  • 1
  • 2
  • 1
    you could leave some code to see well – NHTorres Aug 20 '15 at 17:28
  • @Amjad welcome to StackOverFlow. As pointed out in the first comment, for people to be able to provide appropriate solutions to your question, question needs to be clearer and provide codes so people can have a look at and easily locate the problem. – Want2bExpert Aug 20 '15 at 17:40
  • @Want2bExpert ,sioesi Thanks,I edited my question. – Amjad Aug 20 '15 at 17:57
  • Try to call youradapter.notifydatasetchanged() after list.setAdapter in your activity or fragment class. – Want2bExpert Aug 20 '15 at 18:06
  • I did that but nothing changed – Amjad Aug 20 '15 at 18:09
  • What's the last else for by the way. I believe this if(click_done_btn) represent button.onClickListener? – Want2bExpert Aug 20 '15 at 18:16
  • sorry I edited code, I forget copy some lines .... (click_done_btn) mean i finished delete items and i want hide delete icons. I paste Activity code in question. – Amjad Aug 20 '15 at 18:24
  • Try and have a new handler in each onClickListener that update the View when button is cliecked – Want2bExpert Aug 20 '15 at 18:45
  • I found this explain of "ListView recycling mechanism" stackoverflow.com/questions/11945563/… that will explain the problem ... thank you for help @Wants2bExpert – Amjad Aug 20 '15 at 19:56

1 Answers1

0

This link explain How ListView work ... it's about list

How ListView's recycling mechanism works

thanks @Muhammad Babar

Community
  • 1
  • 1
Amjad
  • 1
  • 2