我试图以编程方式创建一些按钮将它们添加到现有的ViewGroup.这工作正常,但我无法使用正确的样式初始化按钮.
我知道,创建后无法设置/更改视图样式.但到目前为止我发现的所有解决方案都说,使用自定义样式创建视图应该没问题(从我认为的API级别11开始,我使用的是14+):
Button button = new Button (getActivity(), null, R.style.MyButtonStyle);
Run Code Online (Sandbox Code Playgroud)
唯一的效果是,按钮创建时没有任何样式.没有背景,所以选择器,没有边距/填充只是纯文本.我认为MyButtonStyle会被破坏,但是使用MyButtonStyle在XML中创建按钮没问题.
为什么这不起作用?
我在基于Symfony 2.7的WebApp中使用Bootstrap.现在,当在以下内容中使用Bootstrap collapse函数时,我遇到了一个奇怪的问题Form:
该collapse函数用于切换DOM对象的可见性.如果使用此函数来切换a中的元素(例如div容器)Form,则会触发表单验证.
当我在我的服务器上运行我的代码(见下文)时,只要使用按钮切换容器,就会弹出"需要此字段"消息.
这似乎不适用于此.下面的Snippet工作得很好.但是,您可以在w3Schools.com上运行Snippet时看到问题.单击此链接可访问其中一个示例.[R E放置示例代码和我的代码段和运行它.
效果与我的服务器相同:单击切换按钮将触发表单验证.
这只蜜蜂怎么样?有什么区别与这里的Snippet(工作正常)和我的服务器或w3Schools.com上的Snippet(不起作用)?
如何避免表单验证?
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<form action="" method="post" name="custom">
<div class="form-group">
<label class="control-label required" for="name">Name</label>
<input id="name" class="form-control" type="text" required="required" name="custom[name]">
</div>
<button class="btn btn-success" data-target="#toggleContainer" data-toggle="collapse" aria-expanded="true">Toggle</button>
<div id="toggleContainer" aria-expanded="true" style="">
1</br>
2</br>
3</br>
</div>
</form>
</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
在我的Symfony 2.8项目中,我使用包继承来覆盖/扩展FOSUserBundle:自定义包中具有相同路径和名称的文件会覆盖FOSUserBundle.
虽然这对于控制器和资源(如翻译和视图)工作得很好,但它似乎不适用于服务类。
例如,FOSUserBundle用于Resources\config\util.xml定义fos_user.util.password_updater服务以使用 中定义的类Util\PasswordUpdater.php。
简单地将 a 添加Util\PasswordUpdater.php到继承的包中是行不通的。该文件将被忽略,并且捆绑包仍使用原始版本。
这是服务的缩进行为(因为原始服务定义仍然指向原始文件),还是我做错了什么?
覆盖/扩展服务的正确方法是什么?我发现信息表明使用 acompiler pass通常是最好的解决方案。但是,当已经使用包继承时,这也是正确的/有意的吗?
我正在开发一个基于 Symfony 2.8 的项目来管理联系人。用户可以从列表中选择任意数量的联系人,并且应该能够一次删除所有选定的联系人。如何在单个 Query Builder 语句中完成此操作?
// Contact entity uses a GUID as ID
$guids = array(...);
try {
$this->getEntityManager()->getConnection()->beginTransaction();
$qb = $this->getEntityManager()->getConnection()->createQueryBuilder()
->delete('AppBundle:Contact', 'c')
->where('c.guid in (:guids)')
->setParameter(':guids', array($guids, Connection::PARAM_STR_ARRAY));
log($qb->getSql());
$qb->execute();
$this->getEntityManager()->flush();
$this->getEntityManager()->getConnection()->commit();
} catch (\Exception $ex) {
// Rollback the transaction
$this->getEntityManager()->getConnection()->rollback();
}
Run Code Online (Sandbox Code Playgroud)
1. 问题
寻址实体AppBundle:Contact(在构建SELECT语句时没有任何问题)不起作用。这是日志输出:
Query: DELETE FROM AppBundle:Contact c WHERE c.guid in (:guids)
Exception: Doctrine\DBAL\SQLParserUtilsException: Value for :Contact not found in params array. Params array key should be "Contact" in …Run Code Online (Sandbox Code Playgroud) 我正在开发我的第一个Win 8.1 Store应用程序,并且在理解SettingsFlyout时遇到一些麻烦.
感谢为我的自定义设置创建Flyouts并将其添加到Settings Charm 的文档不是问题.
但是,我还没有找到如何在Flyout中导航.我想创建以下行为,因为它可以在邮件应用程序中看到:
步骤1-3没问题.但是我该如何管理其他步骤呢?如何在设置中更深入地导航一个控制杆并使用"后退"按钮再次上升?
我正在Symfony 2.8运行在不同服务器上的两个不同项目。它想使用压缩来加快加载速度。我发现的所有资源都指向mod_deflate。但是,尽管第一台服务器根本不提供mod_deflate,mod_deflate但FastCGI启用后第二台服务器无法使用。
我只发现了可以在服务器(mod_deflate)或“ in script”中启用压缩的信息。但是我没有找到有关此“脚本中”解决方案的任何详细信息。
是否可以在不使用Symfony的情况下启用压缩mod_deflate?
我与斯威夫特5个工作,并试图测试所有NSLayoutContraints的someView,如果他们都涉及到一些otherView:
@IBOutlet var someView: UIView!
@IBOutlet var otherView: UIView!
for constraint in someView.constraints {
if (constraint.firstItem == otherView) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
此代码失败并出现以下错误:
二元运算符“==”不能应用于“AnyObject?”类型的操作数 和“UIView?”
关于 Swift 中的类型和运算符还有很多其他问题,但我仍然不明白为什么会发生这个错误以及如何解决它:
constraint.firstItem是 类型AnyObject?。所以它要么是要么是nil一个类型的对象AnyObjectotherView是类型UIView!,所以保证不是nil,对吗?据我所知AnyObject,所有类都隐式遵守的协议。因此,将任何对象与任何对象进行比较AnyObject?应该不是问题,是吗?
那么,为什么不起作用,解决它constraint.firstItem == otherView的正确方法是什么?
奖金问题:为什么错误消息提到UIView?而不是UIView!
我正在努力将 iOS 13 深色模式支持添加到我的 iOS 11+ 应用程序中。在整个应用程序中使用命名/动态颜色效果很好。
#ffffff但是,当在自定义类中使用 [UIColor colorNamed:] 时,始终返回浅色版本( /白色)而不是深色版本( #000000/黑色):
// Some ViewController
CustomClass *custom = [customClass alloc] initWithTraitCollection:self.traitCollection];
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
custom.traitCollection = self.traitCollection;
}
// CustomClass
- (void)initWithTraitCollection:(UITraitCollection *)traitCollection {
self = [super init];
if (self) {
self.traitCollection = traitCollection;
}
return self;
}
- (void)doSomething {
NSLog(@"CustomClass UIStyle: %@", (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? @"dark" : (self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleLight ? @"light" : @"unspecified")));
// Trying to get the color in …Run Code Online (Sandbox Code Playgroud) 我正在将Windows Phone应用程序移植到Windows 8,我遇到了async/await问题.有一个类需要一段时间才能加载其所有数据.为了不阻止UI线程,加载在单独的任务/线程中完成.加载完成后,需要更新UI线程:
public class MyClass {
public MyClass() {
...
LoadData();
...
}
private async void LoadData() {
Debug.WriteLine("StartLoad: " + Environment.CurrentManagedThreadId);
await ReadDataAsync();
Debug.WriteLine("EndLoad: " + Environment.CurrentManagedThreadId);
UpdateUI();
}
private Task ReadDataAsync() {
return Task.Run(() => {
Debug.WriteLine("Reading: " + Environment.CurrentManagedThreadId);
...Read...
});
}
}
Run Code Online (Sandbox Code Playgroud)
在Windows Phone上,输出是这样的:
StartLoad:1
阅读:4
EndLoad:1
当我在Windows应用商店应用中执行相同的代码时,输出为:
StartLoad:1
阅读:4
EndLoad:4
在Windows Phone上,ThreadId是相同的,在等待Windows 8之后,await之后的ThreadId与await之前的不一样.这是与后台任务中相同的线程.由于这个UpdateUI()在错误的(非UI)线程中执行,应用程序崩溃...
这种不同行为的原因是什么?
..
编辑: 嗯,这很有趣:尽管在这两种情况下,进程都是从同一个线程(3)开始的,但问题只会在进程从App()构造函数启动时显示,而不是从OnLaunched启动时显示.知道为什么会这样吗?
sealed partial class App : Application {
public App() {
this.InitializeComponent();
this.Suspending += …Run Code Online (Sandbox Code Playgroud) 我正在开发一个基于 Java 的 Android 应用程序,它使用自定义 Web 字体来显示不同的图标。为了使用图标,我创建了一个简单的HashMap:
Map<Integer, String> iconMa\xc3\x9f = new HashMap<String, String>() {\n {\n put("help", "\\ue004");\n put("info", "\\ue005");\n ...\n put("search", "\\u0022");\n put("delete", "\\u005c");\n }\n};\nRun Code Online (Sandbox Code Playgroud)\n这工作得很好,除了不可能使用"\\u005c"and 。代表且是。编译器似乎翻译了转义的 unicode 字符,当然它不是有效的字符串。但是,使用\\u005c` (六个字符长)..."\\u0022""\\u0022"""\\u005c"\\"\\""\\\\u005c" does not work either, since now the first backslash escaped the second one and instead of having one unicode character I now get the string
那么,如何正确转义unicode字符呢?
\n当然,我可以通过使用\\and"来解决这个特定问题。但是,我想确保其他字符也不会出现该问题,并且我想知道如何正确转义 unicode 字符。
symfony ×3
ios ×2
android ×1
apache ×1
async-await ×1
button ×1
c# ×1
charms-bar ×1
doctrine ×1
flyout ×1
forms ×1
inheritance ×1
ios-darkmode ×1
java ×1
javascript ×1
objective-c ×1
php ×1
settings ×1
sql ×1
styles ×1
swift ×1
uicolor ×1
unicode ×1
validation ×1