Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Swipe on ListAdapter

$
0
0

Hello Guys...

I am a newbie to xamarin and want to seek advice on following.

I have created an app which ListOut set peoples names and images.Now my requirement is when user swipes on cell of a person it should show details of that paticular person.

Following are codes which I tried.

public class MyScheduleActivity : ListActivity, View.IOnTouchListener
{
    UserDetails noterep = new UserDetails();
    List<UserModel> item = new List<UserModel>();
    Android.Views.ViewGroup parent;
    Android.Views.View convertView;
    private Activity activity;
    private TextView _myButton;
    private float _viewX;
    protected override void OnCreate(Bundle savedInstanceState)
    {
      base.OnCreate(savedInstanceState);
      item = noterep.GetAllNotes();
      ListAdapter = new NoteAdapter(this, this, Resource.Layout.NoteListRow, item.ToArray());
      activity = this;
      var view = (convertView ?? activity.LayoutInflater.Inflate(Resource.Layout.NoteListRow, parent, false)) as LinearLayout;
      _myButton = view.FindViewById<TextView>(Resource.Id.myView);
      _myButton.SetOnTouchListener(this);
    }
     public bool OnTouch(View v, MotionEvent e)
        {
            switch (e.Action)
            {
                case MotionEventActions.Down:
                    _viewX = e.GetX();
                    break;
                case MotionEventActions.Move:
                    var left = (int)(e.RawX - _viewX);
                    var right = (left + v.Width);
                    v.Layout(left, v.Top, right, v.Bottom);
                    break;
            }
            return true;
        }
}

Any Kind of help and suggestions are welcomed.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>