我不确定之前是否有人对这个问题进行了抨击,但对我来说这是一个很大的痛苦.
你如何给android中的xml元素一个id?
现在,我使用模式[活动/片段名称] [元素类型] [特定名称]设置id .例如,如果我有一个EditText来保存在LoginActivity中使用的电子邮件,我将给出id"LoginEditTextEmail".
我面临的问题是,通过这种方法,id通常会在很长的时间内结束.
你如何设置ID?什么是最佳做法?
我有一个包含两个UILabel的自定义视图.我想先定制他们的字体,所以我在initWithCoder方法中做了.
@implementation HomeTitleView
@synthesize ticketLabel;
@synthesize monthLabel;
- (id) initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) {
[monthLabel setFont:[UIFactory getFontForKey:@"home_month"]];
[ticketLabel setFont:[UIFactory getFontForKey:@"home_ticket"]];
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用.使用调试器,我发现monthLabel和ticketLabel都是零.任何人都知道如何解决这个问题?我应该实现什么回调或方法,以便我可以访问我的两个标签?