Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在xamarin.android中设置页面查看器中的自动滑块_Xamarin_Xamarin.android_Xamarin Studio - Fatal编程技术网

如何在xamarin.android中设置页面查看器中的自动滑块

如何在xamarin.android中设置页面查看器中的自动滑块,xamarin,xamarin.android,xamarin-studio,Xamarin,Xamarin.android,Xamarin Studio,我正在尝试在xamarin.android中为页面查看器的代码中添加自动滑块,并尝试了多种方法,但无法正常工作。请您帮助我将自动滑块设置到页面查看器。我正在发布我上一次尝试的代码,该代码自动滑动一页并立即跳到最后一页 使用系统; 使用System.Collections.Generic; 使用System.Linq; 使用系统文本; 使用Android.App; 使用Android.Content; 使用Android.OS; 使用Android.Runtime; 使用Android.Views

我正在尝试在xamarin.android中为页面查看器的代码中添加自动滑块,并尝试了多种方法,但无法正常工作。请您帮助我将自动滑块设置到页面查看器。我正在发布我上一次尝试的代码,该代码自动滑动一页并立即跳到最后一页

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用Android.App;
使用Android.Content;
使用Android.OS;
使用Android.Runtime;
使用Android.Views;
使用Android.Widget;
使用Android.Support.V4.View;
使用Android.Support.V4.App;
使用MyApplication.Droid.Library;
使用系统计时器;
命名空间MyApplication.Droid.Circles
{
[活动(Label=“SampleCirclesSnap”)]
公共类SampleCirclesSnap:碎片活动
{
公共测试碎片适配器;
公众阅览器;
公共页面指示器;
公共定时器时间;
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.simple\u圆圈);
mAdapter=新的TestFragmentAdapter(SupportFragmentManager);
mPager=findviewbyd(Resource.Id.pager);
mPager.Adapter=mAdapter;
var indicator=findviewbyd(Resource.Id.indicator);
mIndicator=指示器;
指示器。设置视图寻呼机(mPager);
指示器。设置捕捉(真);
time=新系统.Timers.Timer();
time.appeased+=(发送方,参数)=>viewPager.SetCurrentItem(CurrentItem++,true);
时间间隔=1000;
time.Enabled=true;
}
}
}
我的碎片相关代码:

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用Android.App;
使用Android.Content;
使用Android.OS;
使用Android.Runtime;
使用Android.Views;
使用Android.Widget;
使用Android.Support.V4.App;
使用Fragment=Android.Support.V4.App.Fragment;
使用FragmentManager=Android.Support.V4.App.FragmentManager;
名称空间MyApplication.Droid
{
公共类TestFragmentAdapter:FragmentPagerAdapter
{
//公共静态字符串[]内容=新字符串[]{“This”、“Is”、“A”、“Test”、};
public static int[]CONTENT=new int[]{Resource.Drawable.Visa,Resource.Drawable.home\u,Resource.Drawable.Set\u,Resource.Drawable.Icon,Resource.Drawable.home\u};
国际计数;
公共TestFragmentAdapter(FragmentManager fm):基本(fm)
{
mCount=CONTENT.Count();
}
公共重写片段GetItem(int位置)
{
返回新的测试片段(内容[位置%CONTENT.Count());
}
公共覆盖整数计数
{
得到
{
返回mCount;
}
}
公共无效集合计数(整数计数)
{
Console.WriteLine(“将计数设置为”+计数);

如果(count>0&&count我认为您需要调用将当前项更改为
RunOnUiThread
方法的方法,以确保它将在UI线程中执行,例如:

var timer=new System.Timers.timer();
计时器。间隔=1000;
timer.Enabled=true;
int page=0;
计时器运行时间+=(发送方,参数)=>
{
RunOnUiThread(()=>
{

如果(页面当我在我的应用程序的仪表板中实现带有点指示器的自动滑块时,它不允许我导航到另一个页面,我在调试时没有遇到此问题,当我从调试中删除时,我遇到此问题。我认为此问题是在绑定圆形页面指示器时出现的,如果可以,您可以帮助我解决此问题。在实现自动滑块@grace feng之前,我曾经遇到过这个问题-msft@ROHITMANDALAPU,您可能需要创建一个新线程并在该问题中发布您的代码。我已通过在一个片段中添加完整的活动解决了此问题。谢谢您的回复。@grace feng msft