我创建了AlertDialog一个AlertDialog.Builder并设置了一些项目setItems().显示对话框但我看不到任何项目.我所看到的只是信息.
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity);
dialogBuilder.setMessage("Pick a color");
dialogBuilder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Do anything you want here
}
});
dialogBuilder.create().show();
Run Code Online (Sandbox Code Playgroud)
如果我设置了PositiveButton,我可以看到那个按钮就好了.我也试过设置MultiChoiceItems,SingleChoiceItems但这些都不起作用.
我有一个iOS应用程序,它将一些敏感信息存储在钥匙串中.在将值写入钥匙串时,我收到错误代码-34018.
我目前正在使用Apple的iOS KeyChainItemWrapper类.
以下两行代码都接收相同的错误代码.
OSStatus res1 = SecItemCopyMatching((__bridge CFDictionaryRef)genericPasswordQuery, (CFTypeRef *)&attributes);
OSStatus res = SecItemUpdate((__bridge CFDictionaryRef)updateItem, (__bridge CFDictionaryRef)tempCheck);
Run Code Online (Sandbox Code Playgroud)
这个问题不是每次都会发生,而是间歇性地发生.一旦我收到此错误,我就无法再将任何值写入钥匙串.
我打印了错误描述,如下所示:
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:res userInfo:nil];
Run Code Online (Sandbox Code Playgroud)
这就是错误打印出来的:
Error: Error Domain=NSOSStatusErrorDomain Code=-34018 "The operation couldn’t be completed. (OSStatus error -34018.)"
Run Code Online (Sandbox Code Playgroud) 这开始发生了.任何想法:代码:
CUSTOMCLASSNAME(我已经替换了实际的类名,因为它包含客户端的名称.)
初始化我的tableView:
[self.tableView registerClass:[CUSTOMCLASSNAME class] forCellReuseIdentifier:[self reuseIdentifier]];
Run Code Online (Sandbox Code Playgroud)
在行的单元格中:
嗨,标题正在控制台中打印.这是我的cellForRow:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AVTCheckListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[self reuseIdentifier] forIndexPath:indexPath];
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
- (void)configureCell:(AVTCheckListTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
ChecklistGroup *group = [self.checklistFetchedResultsController.fetchedObjects objectAtIndex:indexPath.section];
ChecklistItem *item = [self getChecklistItemForIndexPath:indexPath];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
[[cell cellTextView] setAttributedText:[[item checked] boolValue] ? [[NSAttributedString alloc] initWithString:[item name] attributes:@{ NSStrikethroughStyleAttributeName : @(NSUnderlineStyleSingle) } ] : [[NSAttributedString alloc] initWithString:[item name]]];
[[cell cellTextView] setUserInteractionEnabled:[[group isUserDefined] boolValue]];
[[cell cellTextView] setTag:indexPath.row];
[[cell cellTextView] setDelegate:self]; …Run Code Online (Sandbox Code Playgroud) 假设您有2个或更多共享相同结构的网格(行/列数和属性相等).
是否可以创建样式并设置RowDefinitions/ColumnDefinitions?
我试过了.但是当应用程序尝试解析xaml时,我得到此异常:
Xamarin.Forms.Xaml.XamlParseException:位置14:9.属性值为null或不是IEnumerable
我的源代码:
<StackLayout>
<StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Grid">
<Setter Property="RowDefinitions">
<Setter.Value>
<RowDefinition />
<RowDefinition />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</StackLayout.Resources>
<Grid>
<Label Grid.Row="0" Text="(Grid #1) Row #1" />
<Label Grid.Row="1" Text="(Grid #1) Row #2" />
</Grid>
<Grid>
<Label Grid.Row="0" Text="(Grid #2) Row #1" />
<Label Grid.Row="1" Text="(Grid #2) Row #2" />
</Grid>
<Grid>
<Label Grid.Row="0" Text="(Grid #3) Row #1" />
<Label Grid.Row="1" Text="(Grid #3) Row #2" />
</Grid>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
异常中的位置14:9指的是第一个 …
我正在我的应用程序中创建一些应用程序样式,并希望通过键定义一些显式颜色.在WPF XAML中,我将创建一个SolidColorBrush来定义RGB/ARGB值.在Xamarin XAML中,我是否需要将其转换为十六进制以在XAML中定义相同的颜色?下面的代码片段来自WPF XAML.
<SolidColorBrush
x:Key="blueColor">
<SolidColorBrush.Color>
<Color
A="255"
R="50"
G="150"
B="225" />
</SolidColorBrush.Color>
</SolidColorBrush>
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的标签添加右边框.在CSS中,您可以使用几行代码:
label {
border-right : 2px solid #000;
}
Run Code Online (Sandbox Code Playgroud)
这在Xamarin.Forms XAML中似乎有所不同,因为在任何元素上都没有边框属性.这类似于我想要实现的目标:
这是我的代码:
<ListView x:Name="listview" SeparatorVisibility="None"
HasUnevenRows="True" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="20, 10">
<Label Text="{Binding LoremIpsum}"
HorizontalOptions="Start"/>
<Label Text="{Binding LoremIpsum1}" />
<Label Text="{Binding LoremIpsum2}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud)
有什么办法可以在标签上添加右边框吗?我试图用一个BoxView中的同WidthRequest = 1和HeightRequest = 10,但没有奏效.我甚至尝试使用图像,但这不是好习惯.任何帮助,将不胜感激.