【发布时间】:2017-03-03 13:27:36
【问题描述】:
【问题讨论】:
标签: android ios listview xamarin dialog
【问题讨论】:
标签: android ios listview xamarin dialog
我将我的基本页面创建为带有按钮的绝对布局。当我按下按钮时,我将绝对布局 PopUpListView 推到顶部。这是代码。 在主页上
class LoginPage : ContentPage
{
Button btnLogin;
AbsoluteLayout layout;
public LoginPage()
{
layout = new AbsoluteLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
};
BackgroundColor = Color.FromUint(0xFFDBDBDB);
btnLogin = new Button
{
HorizontalOptions = LayoutOptions.FillAndExpand,
Text = "Press me",
BackgroundColor = Color.FromUint(0xFF6E932D),
TextColor = Color.White,
};
btnLogin.Clicked += BtnLogin_Clicked;
layout.Children.Add(btnLogin, new Rectangle(0.5f, 0.1f, 0.25f, 0.25f), AbsoluteLayoutFlags.All);
Content = layout;
}
private void BtnLogin_Clicked(object sender, EventArgs e)
{
layout.Children.Add(new PopUpListView(), new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);
}
}
这是你的弹出窗口
public class PopUpListView : AbsoluteLayout
{
public PopUpListView()
{
BackgroundColor = Color.FromRgba(0, 0, 0, 0.4);
var list = new MyListView();
Children.Add(list, new Rectangle(0.5f, 0.5f, 0.5f, 0.5f), AbsoluteLayoutFlags.All);
}
}
class MyListView : ListView
{
public MyListView()
{
BackgroundColor = Color.Black;
ItemsSource =new string[] {"1 choice", "2 choice", "3 choice" };
}
}
【讨论】: