1

I have an Android Eclair (2.1) phone and I was going through the call log functionality and

I came through a listview in which on touching the left side I am redirected to another listview with more detailed call logs and on the right side I get a "Call" button,

after research and going through multiple posts on the internet I am unable to know how to achieve this, I want to implement this functionality in my application.

Can anyone here please redirect me to any good tutorials which are neat.

Nirali
  • 13,571
  • 6
  • 40
  • 53
Heretic Monk
  • 397
  • 1
  • 5
  • 19

2 Answers2

3

You can do it in getview method in the base adaptor as:

public View getView(final int position, View convertView, ViewGroup parent) {
    DemoClass holder;
    if (convertView == null) {
        convertView = mInflater.inflate(
                R.layout.layout_name, null);
        holder = new DemoClass();
        holder.mTxtVwNameTag = (TextView) convertView
                .findViewById(R.id.TxtVwOptionName);

        holder.mBtnApply = (Button) convertView.findViewById(R.id.BtnApply);// Here you can handle onclick events for list view items

        holder.mBtnApply.setFocusable(false);

        holder.mBtnApply.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                mIntPos = position;
                Log.d("++++++++" , "List item Position : " + mIntPos);
                new ApplyOfferAsync().execute();
            }
        });

        convertView.setTag(holder);
    } else {
        holder = (DemoClass) convertView.getTag();
    }
    try {
        holder.mTxtVwNameTag.setText(mNameTags.get(position));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return convertView;
}
AppMobiGurmeet
  • 719
  • 3
  • 6
1

you have to use touch listener of view or your coustom layout.

wv.setOnTouchListener(new OnTouchListener()
    {

        public boolean onTouch(View arg0, MotionEvent arg1) 
        {
            try
            {
            if(arg1.getAction()==MotionEvent.ACTION_DOWN)
            {
                x_down = (int) arg1.getX();
                y_down = (int) arg1.getY();

            Log.v("log", "x pos is "+x_down +"y pos is "+y_down);
            return true;
            }

            else if(arg1.getAction()==MotionEvent.ACTION_UP)
            {
                x_up = (int) arg1.getX();
                y_up = (int) arg1.getY();

            Log.v("log", "x pos is "+x_up +"y pos is "+y_up);


            if((x_down-x_up)>30)
            {
                //do stuf here
            }
            else if((x_up-x_down)>30)
            {
                 //do stuf here
            }
            return false;
            }
            else
            {
                return false;
            }

            }


            catch (Exception e)
            {
                e.printStackTrace();
                return false;

            }


        }
    });
Sanket Kachhela
  • 10,861
  • 8
  • 50
  • 75