如何获取以# tag开头的字符串数组中的行并显示为标题,使用Xamarin C#

zengzsys  于 2022-12-07  发布在  C#
关注(0)|答案(2)|浏览(108)

我更新了我的问题。
如何获取以#标记开头的行并显示为标题。在下一个#标记之前,所有数据将显示为标题内容。
现在我已经在标签中获取文件数据。我将如何使用这个。使用Xamarin C#。
谢谢你,谢谢你

xlpyo6sf

xlpyo6sf1#

要在标签中输入不同的文本,可以尝试使用spantext,代码如下:

<Label FontSize="16" >
            <Label.FormattedText>
                <FormattedString>
                    <FormattedString.Spans>
                        <Span Text="Hello " x:Name="text1"/>
                        <Span Text="World " FontAttributes="Bold"  x:Name="text2"/>
                    </FormattedString.Spans>
                </FormattedString>
            </Label.FormattedText>
        </Label>

至于具体如何修改,可以在后面的代码中得到span文本,在那里通过Onappearing方法进行处理。

e1xvtsh3

e1xvtsh32#

这就是我的答案,这就是我想做的。

public string UrlFileText { get; set; }
public string[] contentList { get; set; }

WebClient client = new WebClient();          
UrlFileText = client.DownloadString(url);

contentList = UrlFileText.Split("#");
for (int i = 1; i < contentList.Length; i++)
{              
    string[] contentItems = contentList[i].Split("\n", 2);                
    Console.WriteLine("Printing Header of content... \n");
    Console.WriteLine(contentItems[0], "\n");
    Console.WriteLine("Printing content of Content... \n");
    Console.WriteLine(contentItems[1]);
}

相关问题