xamarin android 标签,C#-在Xamarin Android中动态使用

我在xamarin中有一个布局,分为两个部分:标头和正文

取决于属性,我必须更改标题部分.

我创建了2个用作标题部分的布局:header1和header2

我在xamarin android布局中使用标记将标题布局添加到主布局.

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_alignParentTop="true"

layout="@layout/header1" />

但是我不能动态地将layout属性更改为header2吗?

解决方法:

我建议使用ViewSwitcher,因为您只需要在两种布局之间切换:

.axml

android:id="@+id/headerSwitcher"

android:layout_width="match_parent"

android:layout_height="match_parent">

在“活动/片段”上创建一个私有字段,并在OnCreate方法中对其进行初始化:

private Switcher _headerSwitcher;

//Inside your OnCreate

_headerSwitcher = FindViewById(Resource.Id.headerSwitcher);

然后,您可以使用_headerSwitcher.ShowNext()或_headerSwitcher.ShowPrevious()在标题之间进行切换

标签:xamarin,c,android

来源: https://codeday.me/bug/20191119/2040099.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值