Xamarin - 在recyclerview中可滑动的cardview?

时间:2016-01-03 11:08:28

标签: c# android android-fragments xamarin

我正在浏览 fortysevendeg.swipelistview.SwipeListView 。示例应用程序正常运行。

在这里,您可以找到该库的代码和示例 https://github.com/chrisriesgo/android-swipelistview-sharp

这是一个xml文件:

<com.fortysevendeg.swipelistview.SwipeListView xmlns:swipe="http://schemas.android.com/apk/res-auto"
        android:id="@+id/example_lv_list"
        android:listSelector="#00000000"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        swipe:swipeFrontView="@+id/front"
        swipe:swipeBackView="@+id/back"
        swipe:swipeDrawableChecked="@drawable/choice_selected"
        swipe:swipeDrawableUnchecked="@drawable/choice_unselected"
        swipe:swipeCloseAllItemsWhenMoveList="true"
        swipe:swipeMode="both"
        swipe:swipeActionRight="reveal"
        swipe:swipeActionLeft="dismiss"
        swipe:swipeOpenOnLongPress="false" />

这是我的代码

[Activity(Label = "Swipe ListView", MainLauncher = true)]
    public class MainActivity : FragmentActivity
    {
        SwipeListView _swipeListView;
        DogsAdapter _adapter;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            ActionBar.SetIcon(new ColorDrawable(Android.Graphics.Color.Transparent));

            _swipeListView = FindViewById<SwipeListView>(Resource.Id.example_lv_list);

            _adapter = new DogsAdapter(this, Dogs.GetDogData());

            _swipeListView.FrontViewClicked += HandleFrontViewClicked;
            _swipeListView.BackViewClicked += HandleBackViewClicked;
            _swipeListView.Dismissed += HandleDismissed;

            _swipeListView.Adapter = _adapter;
        }

        void HandleFrontViewClicked (object sender, SwipeListViewClickedEventArgs e)
        {
            Toast.MakeText(this,"click",ToastLength.Short);
            RunOnUiThread(() => _swipeListView.OpenAnimate(e.Position));
            //my Stuff to do currently a toast
RunOnUiThread(()=>Toast.MakeText(Application.Context,"click",ToastLength.Short));
        }

        void HandleBackViewClicked (object sender, SwipeListViewClickedEventArgs e)
        {
            RunOnUiThread(() => _swipeListView.CloseAnimate(e.Position));
        }

        void HandleDismissed (object sender, SwipeListViewDismissedEventArgs e)
        {
            foreach (var i in e.ReverseSortedPositions)
            {
                _adapter.RemoveView(i);
            }
        }
    }

当我在未执行的代码中添加额外的东西时。

目前,我已经以两种可能的方式在 HandleFrontViewClicked 中添加了一个祝酒词但没有一个出现。

我想问两个问题:

  1. 我怎样才能做我需要的事情让我们说出来祝酒

  2. 如何在代码

  3. 中检测rightwipe的左侧

    感谢您的帮助

0 个答案:

没有答案