【发布时间】:2018-08-07 13:01:29
【问题描述】:
目前我正在做一个项目,我必须从一个页面 (page1) 导航到另一个页面 (page2)。由于 page2 需要很长时间才能加载,所以我想使用ActivityIndicator,但它根本没有效果。
请给我完整的代码来解决我的问题。
Page(1)
//code for tapping a label and to navigate to page2
void onpage1tapped(Object sender,EventArgs args)
{ label1.Opacity=0.5;
Device.StartTimer(TimeSpan.FromMilliseconds(100),()=>{label1.Opacity=1;return false; })
This.Navigate.PushAsync(new Page2());
}
Page(2)
//constructor for page2
public page2
{ InitializeComponent();
ActivityIndicator indicator=new ActivityIndicator{HorizontalOptions=LayoutOptions.CenterAndExpand,Color=Color.Black,IsVisible=false};
StackLayout stk=new StackLayout();
stk.Children.Add(indicator);
//Enabling activityindicator
indicator.IsRunning=true;
indicator.IsVisible=true;
//Below long time taking task
Assembly assembly = GetType().GetTypeInfo().Assembly;
string resource = String.Format("ks.texts.BST.txt");
//string resource = "advjava.texts.insertion.txt";
using (Stream s = assembly.GetManifestResourceStream(resource))
{
using (StreamReader sr = new StreamReader(s))
{
string line;
while (null != (line = sr.ReadLine()))
{
Label l = new Label { Text = line, TextColor = Color.FromRgb(110, 139, 69), FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) };
stk.Children.Add(l);
}
}
}
//Disabling Activity indicator as the long task is complete
indicator.IsVisible=false;
indicator.IsRunning=false;
}
【问题讨论】:
-
我已经推荐了关注但没有帮助forums.xamarin.com/discussion/22309/…
-
请给我这个问题的完整代码而不是建议链接,因为我已经看过所有在线帮助。
-
基本上这都是关于页面加载的正确指示
-
向我们展示您的代码? :-)
标签: xamarin xamarin.forms