首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有列表视图的老虎机

问具有列表视图的老虎机
EN

Stack Overflow用户
提问于 2017-11-07 05:35:25
回答 1查看 344关注 0票数 0

我想使用代码滚动列表视图。但我不知道卷轴如何在ListView中工作,如何获得职位。我使用ScrollTo来更改位置,但是位置没有改变

计划:滚动的每一个滴答移动位置使用方法ScrollTo。如果是边界,则在反对派边界设置位置。

代码语言:javascript
复制
using Android.App;
using Android.Widget;
using Android.OS;
using System;
using Android.Media;
using System.Collections.Generic;
using Android.Views;

namespace TestChart
{
    [Activity(Label = "Slot Machine", MainLauncher = true)]
    public class MainActivity : Activity
    {
        String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
                "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
                "Linux", "OS/2","Android", "iPhone", "WindowsMobile",
                "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
                "Linux", "OS/2" };


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

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            Button buttonRoll = FindViewById<Button>(Resource.Id.buttonRoll);
            ListView listViewSlotMachine = FindViewById<ListView>(Resource.Id.listViewSlotMachine);

            var adapter = new ArrayAdapter<String>(this, Resource.Layout.my_list_item, values);

            listViewSlotMachine.Adapter = adapter;

            buttonRoll.Click += (sender, e) =>
            {
                listViewSlotMachine.ScrollTo(0, 0); // don't changed
            };
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-07 06:13:23

为了更容易地实现,请使用RecyclerView和recyclerView.smoothScrollTo(位置)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47150652

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档