【发布时间】:2016-04-26 12:33:57
【问题描述】:
我使用 Xamarin 表单。我的 Android 活动扩展了 FormAppCompatActivity。我使用 MasterDetailPage,this.Detail 使用新 NavigationPage(new PagePerso()) 初始化。我有一个 xamarin.forms.view 及其对 Android 的渲染器。 我想把它放在 NavigationBar(Android 的 ActionBar)中。 我尝试使用 NavigationPageRender。然后我尝试使用:
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e){
base.OnElementChanged(e);
Android.Views.View actionBar = base.ViewGroup.GetChildAt(0);
...}
提前感谢您的帮助! 如果您有其他解决方案,请建议我! (我使用 Xamarin 表单、FormAppCompat、MasterDetailPage 和 NavigationPage 到它的详细信息)
解决方案和新问题:
我终于来使用 ViewGroup 在 ActionBar 中添加一个 Android.View。现在,我的问题是我想添加一个自定义视图 (xamarin) ...
Android.Widget.Button bt = new Android.Widget.Button(base.ViewGroup.Context);
ViewGroup actionBar = (ViewGroup) base.ViewGroup.GetChildAt(0);
actionBar.AddView(viewGroup);
这个代码的按钮添加好了。
所以我有MyCustomView view = new MyCustomView();
而且我想以前将视图添加为 viewGroup,但它不是 Android.Views.View。
提前谢谢你!
【问题讨论】:
标签: android xamarin.forms android-appcompat navigationbar appcompatactivity