List View OnitemClick Animation
<p>I did a list view having animation on item click , i am using Array Adapter for the data input and in array adapter i am calling animation class in item click kept the on click variable clickedposition -1 there i call the animation.... all details are in the code .....<br>
`</p>

<pre><code>public class TaskListAdapter extends ArrayAdapter&lt;FTask&gt; {

    protected FTask[] values= null;
    protected Context context = null;
    private int clickedPosition = -1;

    public TaskListAdapter(Context context,FTask[] values) {
        this(context, R.layout.task_row, values);
    }
    public TaskListAdapter(Context context, int taskRow, FTask[] values) {
        super(context, taskRow, values);
        this.values = values;
        this.context = context;

    }
    public void toggle(int position) {
        //If its already opened. Close it. Else open it.
        if(clickedPosition == position){
            clickedPosition = -1;
        }else{
            clickedPosition = position;
        }
        notifyDataSetChanged();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        if (convertView == null) {
            row = View.inflate(context, R.layout.task_row, null);
            LinearLayout single_message_holder = (LinearLayout) row
                    .findViewById(R.id.single_task_holder);
            single_message_holder.setBackgroundColor(Color.WHITE);
        }

        final FTask tsk = values[position];
        TextView service_description = (TextView) row.findViewById(R.id.task_description);
        service_description.setText(tsk.getBody());


        TextView service_detail_description = (TextView) row.findViewById(R.id.task_detail_description);
        service_detail_description.setText(tsk.getBody());
        LinearLayout ani=(LinearLayout)row.findViewById(R.id.ani);


        if (clickedPosition == position) {

            Log.d("****Position*****",String.valueOf(position));
            //service_detail_description.setAnimation(AnimationUtils.loadAnimation(context, 
              //      R.anim.push_up_in));
            ani.startAnimation(new VisibleAni(1.0f, 1.0f, 0.0f, 1.0f, 800, ani, true,true));
            ani.setVisibility(View.VISIBLE);
            service_description.setVisibility(View.GONE);
            Log.d("SENDING TASK STATUS", "AGAINNNNN");
            sendTaskStatus(tsk);

        } else {
            //ani.startAnimation(new VisibleAni(1.0f, 1.0f, 0.0f, 1.0f, 800, ani, true,false));
            ani.setVisibility(View.GONE);
            service_description.setVisibility(View.VISIBLE);

        }

        ImageView icon = (ImageView) row.findViewById(R.id.taskicon);
        if (tsk.isDone()==1) {
            icon.setImageResource(R.drawable.done);
            service_description.setPaintFlags(service_description.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            icon.setImageResource(R.drawable.undone);
            service_description.setPaintFlags(service_description.getPaintFlags() &amp; ~Paint.STRIKE_THRU_TEXT_FLAG );
        }

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

                if(tsk.isDone()==0){
                    tsk.setDone(1);
                    notifyDataSetChanged();
                }
                else{
                    tsk.setDone(0);
                    notifyDataSetChanged();
                }
            }
        });
        return row;
    }
    private void sendTaskStatus(FTask tsk){
        //TODO pathch, 
        Log.e("TaskListAdapter",    "Set status");
        if (LoginManager.getSessionId() == null ||LoginManager.getSessionId().equals("DUMMY") || LoginManager.getSessionId().equals("")){
            Log.e("INVALID USER_ID or SESSION_ID",  "Not connectind to network");
            return;
        }
        NetworkDataFetcher fetcher = new NetworkDataFetcher(NetworkDataFetcher.LINK_DATA_ACCESS);

        try {
            String response = fetcher.execute(new String[] { MessageManager.MSG_JSON_ID_TYPE, MessageManager.MSG_JSON_ID_SESSIONID, MessageManager.MSG_JSON_ID_MID},
                    new String[] {"message_status", LoginManager.getSessionId(), tsk.getTskid() }).get();

            if(response == null){
                Log.e("TaskListAdapter", "response null");
                return;
            }
            Log.w("TasksListAdapter", "Response = "+response);
            return;

        } catch (InterruptedException e) {
            Log.d("InterrupptedException", "InterrupptedException");
            return;
        } catch (ExecutionException e) {
            Log.d("ExecutionException", "ExecutionException");
            return;
        }
    }
}
</code></pre>

<p><code>
And the Animation Class</code></p>

<pre><code>import android.view.View;
import android.view.animation.ScaleAnimation;
import android.view.animation.Transformation;
import android.widget.LinearLayout.LayoutParams;

public class VisibleAni extends ScaleAnimation {
    private View mView;

    private LayoutParams mLayoutParams;

    private boolean mclick;

    private int mMarginBottomFromY, mMarginBottomToY;

    private boolean mVanishAfter = false;

    public VisibleAni(float fromX, float toX, float fromY, float toY, int duration, View view,
            boolean vanishAfter,boolean click) {
        super(fromX, toX, fromY, toY);
        setDuration(duration);
        mView = view;
        mclick = click;
        mVanishAfter = vanishAfter;
        mLayoutParams = (LayoutParams) view.getLayoutParams();
        int height = mView.getHeight();
        mMarginBottomFromY = (int) (height * fromY) + mLayoutParams.bottomMargin - height;
        mMarginBottomToY = (int) (0 - ((height * toY) + mLayoutParams.bottomMargin)) - height;
        if (!mclick) {
            mView.setVisibility(View.GONE); 
        }

    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        super.applyTransformation(interpolatedTime, t);
        if (interpolatedTime &lt; 1.0f) {
            int newMarginBottom = mMarginBottomFromY + (int) ((mMarginBottomToY - mMarginBottomFromY) * interpolatedTime);
            mLayoutParams.setMargins(mLayoutParams.leftMargin, mLayoutParams.topMargin,
                mLayoutParams.rightMargin, newMarginBottom);
            mView.getParent().requestLayout();
        } else if (mVanishAfter ) {
            mView.setVisibility(View.VISIBLE);
        }

    }

}    
</code></pre>

<p><code>
And the XML file related to this is ..........</code></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:descendantFocusability="blocksDescendants"
    &gt;
    &lt;LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/single_task_holder"
        android:gravity="top|left"
        android:paddingRight="10dp"
        android:paddingLeft="0dp"
        android:paddingTop="0dp"
        android:background="@color/white"
        android:orientation="horizontal"

        &gt;

         &lt;LinearLayout
             android:id="@+id/task_icon_lay"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:orientation="horizontal" &gt;

                 &lt;ImageView 
                    android:id="@+id/taskicon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top"        

                    /&gt;


                 &lt;/LinearLayout&gt;
                 &lt;LinearLayout android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:orientation="vertical"&gt;
                &lt;TextView
                    android:id="@+id/task_description"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:layout_width="fill_parent" 
                    android:layout_height="fill_parent"
                    android:paddingBottom="10dp"
                    android:paddingLeft="10dp"
                    android:singleLine="true"
                    android:ellipsize="end"
                    android:paddingRight="20dp"
                    android:textSize="16dp"
                    android:textColor="@color/body_color"
                    /&gt;
                &lt;/LinearLayout&gt;
                &lt;LinearLayout android:layout_width="fill_parent"
                     android:layout_height="wrap_content"
                     android:id="@+id/ani"
                     android:orientation="vertical"&gt;
                &lt;TextView
                    android:id="@+id/task_detail_description"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:background="@android:drawable/edit_text"
                    android:layout_width="fill_parent" 
                    android:layout_height="fill_parent"
                    android:paddingBottom="15dp"
                    android:paddingLeft="15dp"
                    android:paddingTop="15dp"
                    android:paddingRight="20dp"
                    android:textSize="16dp"
                    android:textColor="@color/body_color"
                    /&gt;

                &lt;/LinearLayout&gt;

     &lt;/LinearLayout&gt;


&lt;/LinearLayout&gt;
</code></pre>

<p>`
In first click it worked properly but in second time i clicked the same item it came irregular ..........  </p>
