onClick and onTouch Listener not working properly in android
<p>I have created AdapterClass extending BaseAdapter and i am taking one linearlayout and setting OnClickListener and OnTouchListener to that layout but Both are not working together. If ontouch works on click does not work and if onclick works ontouch does not works. here is my code</p>

<pre><code>public class AdapterClass extends BaseAdapter {

int images[];
Context context;
String string[];
private LayoutInflater inflater;
private int resourceId;
private ArrayList&lt;HashMap&lt;String, String&gt;&gt; myList;
private View view;
private Animation anim_left_right;
private Animation anim_right_left;
private FrameLayout frame;
private LinearLayout ll;
private int width;
private int height;
private String tag;
private boolean flag;

private boolean firstRun = true;
public int closedPosition;
private boolean flagset = true;
private boolean firstRunTouch;
private boolean flag3 = false;
public boolean ff = true;
private View ll1;

public AdapterClass(Context context, int resourceId,
        ArrayList&lt;HashMap&lt;String, String&gt;&gt; myList) {

    this.context = context;
    this.resourceId = resourceId;
    this.myList = myList;

    inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount() {

    return myList.size();
}

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

    System.out.println("Getview Method is called");

    HashMap&lt;String, String&gt; map = getItem(position);

    if (convertView == null) {

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

    }

    ImageView imageView = (ImageView) convertView
            .findViewById(R.id.imageView1);

    System.out.println("hi");

    ll = (LinearLayout) convertView.findViewById(R.id.ll1);
    width = ll.getLayoutParams().width;
    height = ll.getLayoutParams().height;


    frame = (FrameLayout) convertView.findViewById(R.id.frame);

    ll.setOnClickListener(new MyClickListener());

    ll.setOnTouchListener(new MyTouchListener());

    TextView from_user = (TextView) convertView
            .findViewById(R.id.from_user);

    TextView from_user_id = (TextView) convertView
            .findViewById(R.id.from_user_id);

    Button landed = (Button) convertView.findViewById(R.id.button1);
    System.out.println("Tag in side getView :" + ll.getTag());

    if (firstRun) {
        System.out.println("SETTING OPEN...");
        ll.setTag(position);

        closedPosition = 6;
    }

    landed.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Toast.makeText(context,
                    "Button Clicked at position  " + position,
                    Toast.LENGTH_SHORT).show();

        }
    });

    from_user.setText(map.get("from_user"));
    from_user_id.setText(map.get("from_user_id"));

    /*
     * BitmapDrawable d = new BitmapDrawable("/sdcard/NewDownloadJSON/" +
     * map.get("profile_image_url")); imageView.setImageDrawable(d);
     */

    System.out.println("pos" + position + " closedPositon : "
            + closedPosition + " tag : " + ll.getTag());

    String imageUrl = map.get("profile_image_url");


    System.out.println("ClosedPosition in getView Method : "
            + closedPosition);
    return convertView;
}

@Override
public HashMap&lt;String, String&gt; getItem(int arg0) {
    // TODO Auto-generated method stub
    return myList.get(arg0);
}

@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return 0;
}

class MyTouchListener implements OnTouchListener {
    float xstart, xend;

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        anim_left_right = AnimationUtils.loadAnimation(context,
                R.anim.anim_left_to_right1);
        anim_right_left = AnimationUtils.loadAnimation(context,
                R.anim.anim_left_to_right2);

        flag = true;
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            xstart = event.getX();
            firstRun = false;
            break;
        case MotionEvent.ACTION_UP:
            xend = event.getX();
            if (xend &lt; xstart) {
                if (ff) {

                    System.out.println(" xend :" + xend + ", xstart :"
                            + xstart);

                    // closedPosition = (Integer) v.getTag();
                    System.out
                            .println("MyTouchListener is Called before getview..");
                    System.out.println("closdeposiotion : "
                            + closedPosition);

                    v.startAnimation(anim_right_left);
                    v.setLayoutParams(new LayoutParams(150, height));
                    ll1 = v;
                    System.out.println("Tag of ll1 in if statement : "
                            + ll1.getTag()
                            + "Tag of ll1 in if statement : " + v.getTag());
                    ff = false;
                } else {
                    ll1.setLayoutParams(new LayoutParams(width, height));
                    ll1.startAnimation(anim_left_right);
                    System.out.println("Tag of ll1 in else statement : "
                            + ll1.getTag());


                    v.startAnimation(anim_right_left);
                    v.setLayoutParams(new LayoutParams(150, height));
                    System.out.println("Tag of ll1 in else statement : "
                            + v.getTag());
                    ll1 = v;
                }

            }
            if (xstart &lt; xend) {
                System.out
                        .println(" xend :" + xend + ", xstart :" + xstart);

                v.setLayoutParams(new LayoutParams(width, height));
                v.startAnimation(anim_left_right);
                ll1 = null;
                ff = true;

            }
            break;

        }
        return true;
    }
}

class MyClickListener implements OnClickListener {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Animation anim_left_right = AnimationUtils.loadAnimation(context,
                R.anim.anim_left_to_right1);
        Animation anim_right_left = AnimationUtils.loadAnimation(context,
                R.anim.anim_left_to_right2);

        if (ff) {

            // closedPosition = (Integer) v.getTag();
            System.out
                    .println("MyTouchListener is Called before getview..");
            System.out.println("closdeposiotion : " + closedPosition);

            v.startAnimation(anim_right_left);
            v.setLayoutParams(new LayoutParams(150, height));
            ll1 = v;
            System.out.println("Tag of ll1 in if statement : "
                    + ll1.getTag() + "Tag of ll1 in if statement : "
                    + v.getTag());
            ff = false;
        } else {
            ll1.setLayoutParams(new LayoutParams(width, height));
            ll1.startAnimation(anim_left_right);
            System.out.println("Tag of ll1 in else statement : "
                    + ll1.getTag());

            v.startAnimation(anim_right_left);
            v.setLayoutParams(new LayoutParams(150, height));
            System.out.println("Tag of ll1 in else statement : "
                    + v.getTag());
            ll1 = v;
        }

    }

}

}
</code></pre>

<p>Please help me, thanks in advance....</p>
