ex-unit 相关问题


JIRA jql 查询 - * 意味着什么?

JQL 中没有正则表达式: https://answers.atlassian.com/questions/138055/how-can-i-use-regex-in-a-jql-query-i-cannot-match-strings-that-have-a-specific-ending- in-jql-ex-ing-should-match-running-jo...


仅滚动 div 的一部分,而不使用绝对位置和可变高度

HTML: 一些文字 Lorem ipsum dolor sat amet,consectetur HTML: <div class="block"> <div class="header">Some text</div> <div class="content"> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p><p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p><p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p><p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p><p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p><p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque voluptatibus reprehenderit dolorum, ipsam in cumque dicta nisi voluptate fugiat ratione animi. Sint voluptas quod omnis ex magni consequuntur, natus perferendis. </p> </div> </div> CSS: .block { width: 800px; height: 200px; border: 1px solid red; overflow-y: auto; } .content { overflow-y: auto; } 我只想滚动“内容”,我无法设置标题部分的高度,因为它是动态的,所以我也不能使用绝对位置,有没有办法实现这一点? 您可以将 <div class="header">Some text</div> 放在 <div class="block"> 之前。


从单元测试访问 res/raw 文件

在我的Android项目中,我在res/raw/config.json中有一个文件。在Android应用程序中,可以通过resources.openRawResource()访问该文件。 有没有办法,如何从Unit tes访问这个文件...


动态获取父节点及其值

我有一个xml,我可以在其中获取节点中节点的名称,例如值、宽度、高度、重量... 例子: 我有一个 xml,可以在其中获取节点中节点的名称,例如值、宽度、高度、重量…… 示例: <?xml version="1.0" encoding="utf-8"?> <Data totalExecutionTime="00:00:00.0076034" totalCount="1">   <Features>     <ProductID id="100" language="NLB" caption="Product ID" captionAlternative="Product ID" unit="" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="" viewGroup="" viewGroupOrder="0" topViewGroupId="b65b432a-1bf1-4fd4-ae92-03418d3204be" topViewGroup="Algemeen" topViewGroupOrder="1" viewOrder="0" form="Complex" dataType="String" readOnly="False" />     <Length id="245" language="NLB" caption="Lengte" captionAlternative="Lengte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="1" form="Simple" dataType="Number" readOnly="False" />     <Width id="242" language="NLB" caption="Breedte" captionAlternative="Breedte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="2" form="Simple" dataType="Number" readOnly="False" />     <Height id="244" language="NLB" caption="Hoogte" captionAlternative="Hoogte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="3" form="Simple" dataType="Number" readOnly="False" />     <Depth id="771" language="NLB" caption="Diepte" captionAlternative="Diepte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="4" form="Simple" dataType="Number" readOnly="False" />     <Weight id="243" language="NLB" caption="Gewicht" captionAlternative="Gewicht" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="5" form="Simple" dataType="Number" readOnly="False" />     <LoadCapacity id="457" language="NLB" caption="Draagvermogen" captionAlternative="Draagvermogen" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="6" form="Simple" dataType="Number" readOnly="False" />     <Volume id="435" language="NLB" caption="Inhoud" captionAlternative="Inhoud" unit="l" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="bfaf678b-8b9d-4cea-aa99-08edd8316dc7" viewGroup="Algemene specificaties" viewGroupOrder="13" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="7" form="Simple" dataType="Number" readOnly="False" />     <TireSize id="705" language="NLB" caption="Banden maat" captionAlternative="Banden maat" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="8" form="Simple" dataType="String" readOnly="False" />     <LoadingScoop id="706" language="NLB" caption="Laadschep" captionAlternative="Laadschep" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="9" form="Simple" dataType="String" readOnly="False" />   </Features>   <ProductID id="25137" parentId="0" brand="Normal" order="0" createdDate="2020-03-24T15:30:07.21" modifiedDate="2023-11-20T20:01:33.87">     <Value seq="0" modifiedDate="2020-03-24T15:30:10.493">111TA5851</Value>     <Width seq="0" modifiedDate="2020-03-24T15:30:10.493">515</Width>     <Height seq="0" modifiedDate="2020-03-24T15:30:10.493">1100</Height>     <Weight seq="0" modifiedDate="2020-04-02T13:18:09.44">7.7</Weight>     <LoadCapacity seq="0" modifiedDate="2020-03-24T15:30:10.493">150</LoadCapacity>     <LoadingScoop seq="0" modifiedDate="2020-03-24T15:30:10.493">350x170</LoadingScoop>   </ProductID> </Data> 我想要的是动态获取对应父节点的hte值。我可以获得如下节点名称: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table> <xsl:for-each select="/Data/ProductID/*"> <xsl:variable name="myVariable" select="name(.)"/> <xsl:variable name="HasValue" select="count(/Data/ProductID/*)" /> <tr> <td><xsl:value-of select="name(.)" /></td> <td><xsl:value-of select="local-name()" /></td> <td><xsl:value-of select="name()" /></td> <td><xsl:value-of select="/Data/node($myVariable)/@unit" /></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> 但是我不知道如何获取相应的父节点及其值,例如单位元素。 我已经尝试过<xsl:value-of select="/Data/$myVariable/@unit" /></td>,但不起作用。我会不断收到错误:Unexpected token '$myVariable' during parsing of '<AnyKindTest>'。 我想你想声明一把钥匙 <xsl:key name="element-key" match="Data/Features" use="name()"/> 然后你想使用例如key('element-key', name())/@unit。 你写道: <xsl:value-of select="/Data/$myVariable/@unit" /> 我认为你的问题可能是重复的 使用 2 个参数进行 xslt 测试 您正在尝试使用 $myVariable,就好像它所保存的字符串可以以文本方式替换到您的 XPath 表达式中一样。您可能想要的是 /Data/*[name()=$myVariable]/@unit 很多人都犯过这个错误,但我不知道为什么。我不认为人们会将变量 $op 设置为“+”或“-”,然后期望 @x $op @y 执行适当的加法或减法。除非他们以前的编程经验完全是用宏语言。


使用 Maven 和 junit 启用预览

我正在使用模式匹配开关编写一些Java代码,这需要在多个上下文(编译器、运行时、IDE)中设置--enable-preview。此时,除了其中一个之外,我已经得到了所有内容:unit


python 类型上的partial()?

我经常使用类型提示来帮助记录代码,有时当类型签名过于复杂并重复使用时,我会像这样给它们起别名: MyType = Dict[Tuple[int,...], float] # ex: cl...


XSL/XSLT - 动态获取父节点及其值

有人可以帮助我吗?我有一个 xml,可以在其中获取节点中节点的名称,例如值、宽度、高度、重量…… 例子: 有人可以帮助我吗?我有一个 xml,可以在其中获取节点中节点的名称,例如值、宽度、高度、重量…… 示例: <?xml version="1.0" encoding="utf-8"?> <Data totalExecutionTime="00:00:00.0076034" totalCount="1">   <Features>     <ProductID id="100" language="NLB" caption="Product ID" captionAlternative="Product ID" unit="" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="" viewGroup="" viewGroupOrder="0" topViewGroupId="b65b432a-1bf1-4fd4-ae92-03418d3204be" topViewGroup="Algemeen" topViewGroupOrder="1" viewOrder="0" form="Complex" dataType="String" readOnly="False" />     <Length id="245" language="NLB" caption="Lengte" captionAlternative="Lengte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="1" form="Simple" dataType="Number" readOnly="False" />     <Width id="242" language="NLB" caption="Breedte" captionAlternative="Breedte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="2" form="Simple" dataType="Number" readOnly="False" />     <Height id="244" language="NLB" caption="Hoogte" captionAlternative="Hoogte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="3" form="Simple" dataType="Number" readOnly="False" />     <Depth id="771" language="NLB" caption="Diepte" captionAlternative="Diepte" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="4" form="Simple" dataType="Number" readOnly="False" />     <Weight id="243" language="NLB" caption="Gewicht" captionAlternative="Gewicht" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="28813941-54b4-4511-b91e-d9ae53aa03e9" viewGroup="Afmetingen en gewicht" viewGroupOrder="91" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="5" form="Simple" dataType="Number" readOnly="False" />     <LoadCapacity id="457" language="NLB" caption="Draagvermogen" captionAlternative="Draagvermogen" unit="kg" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="6" form="Simple" dataType="Number" readOnly="False" />     <Volume id="435" language="NLB" caption="Inhoud" captionAlternative="Inhoud" unit="l" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="bfaf678b-8b9d-4cea-aa99-08edd8316dc7" viewGroup="Algemene specificaties" viewGroupOrder="13" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="7" form="Simple" dataType="Number" readOnly="False" />     <TireSize id="705" language="NLB" caption="Banden maat" captionAlternative="Banden maat" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="8" form="Simple" dataType="String" readOnly="False" />     <LoadingScoop id="706" language="NLB" caption="Laadschep" captionAlternative="Laadschep" unit="mm" help="" abbr="" groupId="73660834-eea8-4d67-8e84-b38e2742706a" group="Alles" groupOrder="0" viewGroupId="c9d7dd7e-8a85-47cc-8542-2695e4615f75" viewGroup="Technische specificaties" viewGroupOrder="15" topViewGroupId="590c0ee7-e1eb-4e18-b583-eba8984ffe82" topViewGroup="Specificaties" topViewGroupOrder="4" viewOrder="9" form="Simple" dataType="String" readOnly="False" />   </Features>   <ProductID id="25137" parentId="0" brand="Normal" order="0" createdDate="2020-03-24T15:30:07.21" modifiedDate="2023-11-20T20:01:33.87">     <Value seq="0" modifiedDate="2020-03-24T15:30:10.493">111TA5851</Value>     <Width seq="0" modifiedDate="2020-03-24T15:30:10.493">515</Width>     <Height seq="0" modifiedDate="2020-03-24T15:30:10.493">1100</Height>     <Weight seq="0" modifiedDate="2020-04-02T13:18:09.44">7.7</Weight>     <LoadCapacity seq="0" modifiedDate="2020-03-24T15:30:10.493">150</LoadCapacity>     <LoadingScoop seq="0" modifiedDate="2020-03-24T15:30:10.493">350x170</LoadingScoop>   </ProductID> </Data> 我想要的是动态获取对应父节点的值。我可以获得如下节点名称: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table> <xsl:for-each select="/Data/ProductID/*"> <xsl:variable name="myVariable" select="name(.)"/> <xsl:variable name="HasValue" select="count(/Data/ProductID/*)" /> <tr> <td><xsl:value-of select="name(.)" /></td> <td><xsl:value-of select="local-name()" /></td> <td><xsl:value-of select="name()" /></td> <td><xsl:value-of select="/Data/node($myVariable)/@unit" /></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> 但我不知道如何获取响应的父节点及其值,例如单位元素。 提前致谢并致以诚挚的问候 我已经尝试过但没用。我会不断收到错误:解析 '' 期间出现意外的标记 '$myVariable'。 我想你想声明一把钥匙 <xsl:key name="element-key" match="Data/Features" use="name()"/> 然后你想使用例如key('element-name', name())/@unit。


需要Google Sheets列表功能

我正在尝试创建一个函数,列出 A-F 每列中值等于 0 的任何单元格的名称。 EX: 我希望 A:32 显示值小于 1 的任何单元格的名称。 ..


pymodbus read_coils 返回丢失的 1 字节 CRC

我正在尝试通过 pymodbus 控制 EX-PS 5080 电源。我正在尝试读取远程状态。 Modbus 地址 = 402;功能码 = 01 读取线圈;数据类型 = uint(16);数据长度(以字节为单位)= 2;


如果超过阈值,JMeter 测试失败

我希望我能在这里找到帮助,因为我在互联网上没有找到任何东西。我有多个 JMeter 计划,如果一组请求的吞吐量阈值是 ex,我希望该计划失败...


在 Shree-Lipi Nxt 中安装字体时出现 EConvertError 错误

我已经安装了Shree Lipi Nxt版本8.1.8682.19818,一个打字工具。但问题是当我尝试安装任何语言的 Shree-Lipi ex 字体时,它会出现以下错误。 但这个错误确实...


在java中检查集合/列表是否为空并返回大小为0的实用程序

我有一个有时可能为空的列表,返回类型应该是 int ex: 整数大小=0; 如果(列表!=空){ 大小=列表.大小; } 您能否告诉我是否有可用的实用程序...


.NET MAUI:自定义Shell TitleView并绑定到当前页面标题

我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: 我想用我自己的自定义布局替换默认的 Shell 标头,如下所示: <?xml version="1.0" encoding="UTF-8" ?> <Shell x:Class="MyNamespace.App.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:MyNamespace.App" xmlns:pages="clr-namespace:MyNamespace.App.Pages" BindingContext="{x:Static local:MainView.Instance}" Shell.FlyoutBehavior="{Binding ShellFlyoutType}" x:Name="shellMain"> <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" Text="{Binding Path=CurrentPage.Title, Mode=OneWay}" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> <ShellContent Title=" Login" ContentTemplate="{DataTemplate local:MainPage}" Route="login" FlyoutItemIsVisible="False" /> <ShellContent Title="Dashboard" ContentTemplate="{DataTemplate pages:DashboardPage}" Route="dashboard" /> </Shell> 我无法绑定当前页面标题。 我的 AppShell.xaml Shell 声明如下 <Shell ... x:Name="shellMain"> 作为替代方案,您可以在 OnNaviged 方法中设置 titleview : 在 AppShell.xaml 中,定义标签的名称 <Shell.TitleView> <Grid ColumnDefinitions="*,200"> <Label BindingContext="{x:Reference shellMain}" x:Name="mylabel" FontSize="Large" TextColor="White" /> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="Orange" Grid.Column="1" HorizontalOptions="End" /> </Grid> </Shell.TitleView> 在AppShell.xaml.cs中,重写OnNaviged方法,获取当前项目 protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); var shellItem = Shell.Current?.CurrentItem; string title = shellItem?.Title; int iterationCount = 0; while (shellItem != null && title == null) { title = shellItem.Title; shellItem = shellItem.CurrentItem; if (iterationCount > 10) break; // max nesting reached iterationCount++; } myLabel.Text = title; } 希望它对你有用。 我正在尝试同样的方法来修改 TitleView 的外观。它可以在 iOS 上运行,尽管那里还有另一个错误。但在 Android 上我遇到了同样的问题。在前进导航中,它会更新标题,但当您按后退按钮时,标题不会更新。我已经打开了一个问题并添加了一个存储库。 https://github.com/dotnet/maui/issues/12416#issuecomment-1372627514 还有其他方法可以修改TitleView的外观吗? 我使用视图模型开发了这个解决方法,主要不是为了提供 MVVM 解决方案,而是因为其他建议的答案对我不起作用。 (我怀疑 Liqun Shen 2 月 15 日针对他自己的问题的评论中的建议会起作用。但我没有注意到这一点,直到我自己修复)。 当前页面的标题保存在可由 shell 的视图模型和每个内容页面的视图模型访问的类中: public class ServiceHelper { private static ServiceHelper? _default; public static ServiceHelper Default => _default ??= new ServiceHelper(); internal string CurrentPageTitle { get; set; } = string.Empty; } shell 中每个内容页面的视图模型提供其页面标题。为了促进这一点,大部分工作都是由基本视图模型完成的,它们都是从该模型派生而来的: public abstract class ViewModelBase(string title) : ObservableObject { private ServiceHelper? _serviceHelper; public string Title { get; } = title; internal ServiceHelper ServiceHelper { get => _serviceHelper ??= ServiceHelper.Default; set => _serviceHelper = value; // For unit testing. } public virtual void OnAppearing() { ServiceHelper.CurrentPageTitle = Title; } } 每个 shell 内容页面视图模型只需要让其基础视图模型知道它的标题: public class LocationsViewModel : ViewModelBase { public LocationsViewModel() : base("Locations") { } } 每个 shell 内容页面都需要在其视图模型中触发所需的事件响应方法: public partial class LocationsPage : ContentPage { private LocationsViewModel? _viewModel; public LocationsPage() { InitializeComponent(); } private LocationsViewModel ViewModel => _viewModel ??= (LocationsViewModel)BindingContext; protected override void OnAppearing() { base.OnAppearing(); ViewModel.OnAppearing(); } } Shell 的视图模型为标题栏提供当前页面的标题: public class AppShellViewModel() : ViewModelBase(Global.ApplicationTitle) { private string _currentPageTitle = string.Empty; public string CurrentPageTitle { get => _currentPageTitle; set { _currentPageTitle = value; OnPropertyChanged(); } } public void OnNavigated() { CurrentPageTitle = ServiceHelper.CurrentPageTitle; } } Shell 需要在其视图模型中触发所需的事件响应方法: public partial class AppShell : Shell { private AppShellViewModel? _viewModel; public AppShell() { InitializeComponent(); } private AppShellViewModel ViewModel => _viewModel ??= (AppShellViewModel)BindingContext; protected override void OnNavigated(ShellNavigatedEventArgs args) { base.OnNavigated(args); ViewModel.OnNavigated(); } } 最后,Shell 的 XAML 在标题栏/导航栏上显示由 Shell 视图模型提供的当前页面的标题: <Shell.TitleView> <HorizontalStackLayout VerticalOptions="Fill"> <Image Source="falcon_svg_repo_com.png" HeightRequest="50"/> <Label x:Name="CurrentPageTitleLabel" Text="{Binding CurrentPageTitle}" FontSize="24" Margin="10,0" VerticalTextAlignment="Center"/> </HorizontalStackLayout> </Shell.TitleView>


SecurityException:不允许启动服务Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (有额外功能)}

我尝试从 Google 获取我的 GCM 注册 ID。 我的代码: 字符串SENDER_ID =“722*****53”; /** * 向 GCM 服务器异步注册应用程序。 * * 存储注册信息... 我尝试从 Google 获取我的 GCM 注册 ID。 我的代码: String SENDER_ID = "722******53"; /** * Registers the application with GCM servers asynchronously. * <p> * Stores the registration ID and the app versionCode in the application's * shared preferences. */ private void registerInBackground() { new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... params) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration ID=" + regid; // You should send the registration ID to your server over // HTTP, so it // can use GCM/HTTP or CCS to send messages to your app. sendRegistrationIdToBackend(); // For this demo: we don't need to send it because the // device will send // upstream messages to a server that echo back the message // using the // 'from' address in the message. // Persist the regID - no need to register again. storeRegistrationId(context, regid); } catch (IOException ex) { msg = "Error :" + ex.getMessage(); // If there is an error, don't just keep trying to register. // Require the user to click a button again, or perform // exponential back-off. } return msg; } @Override protected void onPostExecute(String msg) { mDisplay.append(msg + "\n"); } }.execute(null, null, null); } 我收到错误: 03-01 19:15:36.261: E/AndroidRuntime(3467): FATAL EXCEPTION: AsyncTask #1 03-01 19:15:36.261: E/AndroidRuntime(3467): java.lang.RuntimeException: An error occured while executing doInBackground() 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$3.done(AsyncTask.java:299) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.setException(FutureTask.java:219) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.run(FutureTask.java:239) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.lang.Thread.run(Thread.java:841) 03-01 19:15:36.261: E/AndroidRuntime(3467): Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.app.ContextImpl.startServiceAsUser(ContextImpl.java:1800) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.app.ContextImpl.startService(ContextImpl.java:1772) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.content.ContextWrapper.startService(ContextWrapper.java:480) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.google.android.gms.gcm.GoogleCloudMessaging.b(Unknown Source) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.example.gcm.DemoActivity$1.doInBackground(DemoActivity.java:177) 03-01 19:15:36.261: E/AndroidRuntime(3467): at com.example.gcm.DemoActivity$1.doInBackground(DemoActivity.java:1) 03-01 19:15:36.261: E/AndroidRuntime(3467): at android.os.AsyncTask$2.call(AsyncTask.java:287) 03-01 19:15:36.261: E/AndroidRuntime(3467): at java.util.concurrent.FutureTask.run(FutureTask.java:234) 03-01 19:15:36.261: E/AndroidRuntime(3467): ... 4 more 这是我的清单: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.manyexampleapp" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="com.example.manyexampleapp.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.example.manyexampleapp.gcm.permission.C2D_MESSAGE" /> <permission android:name="com.example.manyexampleapp.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <application android:name="com.zoomer.ifs.BaseApplication" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name="com.zoomer.ifs.MainActivity" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTop"> <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <!-- PUSH --> <!-- WakefulBroadcastReceiver that will receive intents from GCM services and hand them to the custom IntentService. The com.google.android.c2dm.permission.SEND permission is necessary so only GCM services can send data messages for the app. --> <receiver android:name="com.example.gcm.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.example.manyexampleapp" /> </intent-filter> </receiver> <service android:name="com.example.gcm.GcmIntentService" /> <activity android:name="com.example.gcm.DemoActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!-- DB --> <activity android:name="com.example.db.DbActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.http.RestGetActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > </activity> <activity android:name="com.example.fb.FacebookLoginActivity" android:label="@string/app_name" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.example.http.SendFeedbackActivity" android:label="@string/app_name" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.zoomer.general.SearchNearbyOffersActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.facebook.LoginActivity" android:label="@string/app_name" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.manyexampleapp.StoresListActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.fb.ShareActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.notifications.NotificationsActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.example.fb2.no_use.MainActivity" > <intent-filter> </intent-filter> </activity> <activity android:name="com.zoomer.offers.OffersListActivity" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <activity android:name="com.example.http.SearchNearbyOffersActivity" > <!-- <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> --> </activity> <service android:name="com.example.geo.LocationService" android:enabled="true" /> <receiver android:name="com.example.manyexampleapp.BootReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="com.example.manyexampleapp.LocationService.LOCATION_BROAD_MSG" /> </intent-filter> </receiver> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id" /> </application> </manifest> 改变 <uses-permission android:name="com.example.manyexampleapp.c2dm.permission.RECEIVE" /> 到 <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 您收到异常是因为您尚未定义所需的权限 如果应用程序开发后安装了播放服务, 可能会发生 com.google.android.c2dm.permission.RECEIVE 权限已被授予但 android 仍在抱怨同样的错误。 在这种情况下,您必须完全重新安装开发的应用程序才能使此权限发挥作用。 我认为你必须检查 Kotlin 版本兼容性。


© www.soinside.com 2019 - 2024. All rights reserved.