1) Клонирование SwipyRefreshLayout
репо
2) Построить проект в Android Studio произвести выпуск отладки & aar
«ы
3) Используйте релиз aar
в вашем Xamarin.Android
связывания проекта
./lib/build/outputs/aar/lib-release.aar
5) Добавить проект связывания в качестве ссылки на ваш Xamarin.Android
приложение.
4) Добавить ресурсы Swipy Java Тестовые приложения для вашего # приложение C
Примечание: Это просто ярлык, чтобы пропустить, чтобы вручную обновить их для тестового приложения.
5) Пример C# Swipy код:
[Activity(Label = "Swipy", MainLauncher = true, Icon = "@mipmap/icon")]
public class MainActivity : Activity
{
string[] items;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
Button buttonTop = FindViewById<Button>(Resource.Id.button_top);
buttonTop.Click += onClick;
Button buttonBottom = FindViewById<Button>(Resource.Id.button_bottom);
buttonBottom.Click += onClick;
Button buttonRefresh = FindViewById<Button>(Resource.Id.button_refresh);
buttonRefresh.Click += onClick;
Button buttonBoth = FindViewById<Button>(Resource.Id.button_both);
buttonBoth.Click += onClick;
items = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", };
var ListAdapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, items);
ListView listview = FindViewById<ListView>(Resource.Id.listview);
listview.Adapter = ListAdapter;
SwipyRefreshLayout swipyrefreshlayout = FindViewById<SwipyRefreshLayout>(Resource.Id.swipyrefreshlayout);
swipyrefreshlayout.Refresh += async (object sender, SwipyRefreshLayout.RefreshEventArgs e) =>
{
Log.Debug("MainActivity", "Refresh triggered at " + (e.Direction == SwipyRefreshLayoutDirection.Top ? "top" : "bottom"));
swipyrefreshlayout.Refreshing = true;
await Task.Delay(2000); // simulate some data refresh
RunOnUiThread(() =>
{
swipyrefreshlayout.Refreshing = false;
});
};
}
async void onClick(object sender, EventArgs e)
{
SwipyRefreshLayout swipyrefreshlayout = FindViewById<SwipyRefreshLayout>(Resource.Id.swipyrefreshlayout);
var v = (View)sender;
switch (v.Id)
{
case Resource.Id.button_top:
swipyrefreshlayout.Direction = SwipyRefreshLayoutDirection.Top;
break;
case Resource.Id.button_bottom:
swipyrefreshlayout.Direction = SwipyRefreshLayoutDirection.Bottom;
break;
case Resource.Id.button_both:
swipyrefreshlayout.Direction = SwipyRefreshLayoutDirection.Both;
break;
case Resource.Id.button_refresh:
swipyrefreshlayout.Refreshing = true;
await Task.Delay(2000); // simulate some data refresh
RunOnUiThread(() =>
{
swipyrefreshlayout.Refreshing = false;
});
break;
}
}
}
Спасибо, так оно и было. – Erli