91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

XamarinAndroid組件教程RecylerView動畫組件使用動畫(3)

發布時間:2020-08-12 01:48:33 來源:ITPUB博客 閱讀:121 作者:大學霸 欄目:移動開發

XamarinAndroid組件教程RecylerView動畫組件使用動畫(3)

8)打開Main.axml文件,構建主界面。代碼如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

              android:orientation="vertical"

              android:layout_width="match_parent"

              android:layout_height="match_parent">

  <android.support.v7.widget.Toolbar

      android:id="@+id/tool_bar"

      android:layout_width="match_parent"

      android:layout_height="wrap_content"

      android:background="#3DC49D"

      android:minHeight="?attr/actionBarSize">

      <RelativeLayout

          android:layout_width="match_parent"

          android:layout_height="wrap_content">

          <TextView

              android:id="@+id/del"

              android:layout_width="wrap_content"

              android:layout_height="wrap_content"

              android:layout_alignParentRight="true"

              android:layout_centerInParent="true"

              android:background="?attr/selectableItemBackground"

              android:padding="10dp"

              android:text="DEL"/>

          <TextView

              android:id="@+id/add"

              android:layout_width="wrap_content"

              android:layout_height="wrap_content"

              android:layout_toLeftOf="@id/del"

              android:layout_centerInParent="true"

              android:background="?attr/selectableItemBackground"

              android:padding="10dp"

              android:text="ADD"/>

      </RelativeLayout>

  </android.support.v7.widget.Toolbar>

  <android.support.v7.widget.RecyclerView

      android:id="@+id/list"

      android:layout_width="match_parent"

      android:layout_height="match_parent"/>

</LinearLayout>

9)打開MainActivity.cs文件,設置RecylerView子元素添加和刪除時的動畫效果。代碼如下:

using Android.App;

using Android.Widget;

using Android.OS;

using Android.Support.V7.Widget;

using System.Linq;

using RecyclerViewAnimators.Animators;

using Android.Support.V7.App;

namespace RecylerViewAnimatorsItemAnimator

{

    [Activity(Label = "RecylerViewAnimatorsItemAnimator", MainLauncher = true, Icon = "@mipmap/icon", Theme = "@style/AppTheme")]

    public class MainActivity : AppCompatActivity

    {

        static readonly string[] data = {

            "Apple", "Ball", "Camera", "Day", "Egg", "Foo", "Google", "Hello", "Iron", "Japan", "Coke",

            "Dog", "Cat", "Yahoo", "Sony", "Canon", "Fujitsu", "USA", "Nexus", "LINE", "Haskell", "C++",

            "Java", "Go", "Swift", "Objective-c", "Ruby", "PHP", "Bash", "ksh", "C", "Groovy", "Kotlin",

            "Chip", "Japan", "U.S.A", "San Francisco", "Paris", "Tokyo", "Silicon Valley", "London",

            "Spain", "China", "Taiwan", "Asia", "New York", "France", "Kyoto", "Android", "Google", "C#",

            "iPhone", "iPad", "iPod", "Wasabeef", "Xamarin", "South Africa", "Cape Town", "Microsoft"

        };

        protected override void OnCreate(Bundle savedInstanceState)

        {

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.tool_bar);

            SetSupportActionBar(toolbar);

            SupportActionBar.SetDisplayShowTitleEnabled(false);

            var recyclerView = FindViewById<RecyclerView>(Resource.Id.list);

            recyclerView.SetLayoutManager(new LinearLayoutManager(this));              //設置布局管理

            var datalist = data.ToList<string>();

            var adapter = new DataAdapter(this, datalist);

            recyclerView.SetAdapter(adapter);                                                                        //設置適配器

            recyclerView.SetItemAnimator(new FlipInLeftYAnimator());                        //設置動畫效果

            //添加子元素

            FindViewById(Resource.Id.add).Click += (sender, e) => {

                adapter.Add("newly added item", 1);

            };

            //刪除子元素

            FindViewById(Resource.Id.del).Click += (sender, e) => {

                adapter.Remove(1);

            };

        }

    }

}

運行程序后,初始狀態如圖1.1所示。輕拍Add按鈕,實現子元素的添加,在添加子元素的時候會伴有指定動畫效果,如圖1.2所示。輕拍DEL按鈕,實現子元素的刪除,在子元素刪除的過程中也會伴有指定的動畫效果。

XamarinAndroid組件教程RecylerView動畫組件使用動畫(3)

1.1  初始狀態                          1.2  添加數據

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

盐亭县| 浙江省| 如皋市| 中山市| 韶山市| 卢龙县| 万山特区| 富阳市| 北流市| 鄂州市| 行唐县| 塔河县| 明溪县| 泰和县| 平塘县| 前郭尔| 建湖县| 克什克腾旗| 科技| 霍城县| 和田市| 贵州省| 全州县| 耒阳市| 潍坊市| 双城市| 渭源县| 新干县| 西藏| 荆州市| 南汇区| 楚雄市| 涞源县| 夹江县| 宁河县| 昌乐县| 都昌县| 大邑县| 同心县| 甘孜| 辛集市|