对不起我的英语不好.我尝试改变动作栏collor.我有这个错误:
错误:检索项目的父项时出错:找不到与给定名称"@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"匹配的资源.
我有minSdkVersion = 12
style.xml
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
//this is error
<style name="MyActionBar" parent="@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#FF9D21</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
UPD
我添加了appcompat_v7,但它不起作用
UPD
现在style.xml看起来:
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#FF9D21</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在清单中:
android:theme="@style/MyTheme" >
Run Code Online (Sandbox Code Playgroud)
我有错误:
03-05 12:45:33.860:E/AndroidRuntime(2006):java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.test6/com.example.test6.MainActivity}:java.lang.IllegalStateException:You需要在此活动中使用Theme.AppCompat主题(或后代).
如果我改变那样的清单:
android:theme="@style/Theme.AppCompat" >
Run Code Online (Sandbox Code Playgroud)
没有错误,但在此之后没有更改颜色操作栏
我正在为django表单编写一个模板.我想在迭代所有表单字段时确定字段的类型(输入标记内的type属性).
当我写{{ field }}
它给我<input id="id_file" name="file" type="file">
,它没关系,但我想覆盖输入标签(使用bootstrap).因此,我需要{{ field.type }}
写点东西<input name="{{ field.html_name }}" type="{{ field.type}}" id="{{ field.id_for_label }}" class="form-control">
可以通过使用过滤器来解决这个问题,但坦率地说我不能这样做.
该http://clojure.org/data_structures页解释了所有的Clojure集合为"不可改变的,持久的".我一直在寻找一个明确的定义,确切地说"持久性"在这种情况下意味着什么,以及是否有人对此有明确的解释?
我正在寻找一个很好的资源,它将向我展示构建一个安静的API的正确方法.有趣的主题:特别是身份验证和一般安全性,性能,可伸缩性,最佳实践和其他有用的东西.
我将用PHP(Slim或Silex)构建它,在开始之前我想考虑整个设计,所以我可以从一开始就采用正确的方法.
网络上有很多信息和帖子,但他们都采用不同的做法和方法.
在宁静的世界里,有什么东西似乎是"标准"吗?
我是否忘记了显而易见的,或者是"手动"比较器最好的方法?
基本上,我只想比较类型(小)字节数组的内容.如果所有字节都匹配,则结果应为true,否则为false.
我期待找到那个Array.Equals
或者Buffer.Equals
会有所帮助.
示范代码:
var a = new byte[]{1, 2, 3, 4, 5};
var b = new byte[]{1, 2, 3, 4, 5};
Console.WriteLine(string.Format("== : {0}", (a == b)));
Console.WriteLine(string.Format("Equals : {0}", a.Equals(b)));
Console.WriteLine(string.Format("Buffer.Equals : {0}", Buffer.Equals(a, b)));
Console.WriteLine(string.Format("Array.Equals = {0}", Array.Equals(a, b)));
Console.WriteLine(string.Format("Manual_ArrayComparer = {0}", ArrayContentsEquals(a, b)));
Run Code Online (Sandbox Code Playgroud)
手动功能:
/// <summary>Returns true if all elements of both byte-arrays are identical</summary>
public static bool ArrayContentsEquals(byte[] a, byte[] b, int length_to_compare = int.MaxValue)
{
if (a == null || …
Run Code Online (Sandbox Code Playgroud) 以下Python片段给出了一个错误:
df = pandas.DataFrame({'A': ['UBS','UBS','ABB','UBS'], 'B': ['L', 'L', 'L', 'D']})
cols = ['A', 'A', 'B']
df = df[cols]
df = df[df['A'].isin(['UBS']) & (df['B'] != 'D')]
Run Code Online (Sandbox Code Playgroud)
我得到的错误是unorderable types: str() < int()
.我会理解它是否抱怨重复列,但为什么它尝试(并且失败)比较整数和字符串?
如果我替换最后一行,df = df[df['A'].isin(['UBS'])]
我会得到预期的错误消息,cannot reindex from a duplicate axis
.
不可否认,这个例子是设计的(它是真实代码的一个简化示例),如果我交换最后两行代码可以正常工作,但我仍然想了解错误.
正如我所说,我想在GLSL的计算着色器中实现我自己的双精度cos()函数,因为只有一个内置的float版本.
这是我的代码:
double faculty[41];//values are calculated at the beginning of main()
double myCOS(double x)
{
double sum,tempExp,sign;
sum = 1.0;
tempExp = 1.0;
sign = -1.0;
for(int i = 1; i <= 30; i++)
{
tempExp *= x;
if(i % 2 == 0){
sum = sum + (sign * (tempExp / faculty[i]));
sign *= -1.0;
}
}
return sum;
}
Run Code Online (Sandbox Code Playgroud)
这段代码的结果是,着色器上的总和是NaN,但在CPU上,算法运行良好.我也尝试调试此代码,并获得以下信息:
现在我的问题是:如果每个变量都是一个数字并且什么都没有被零除,那么究竟什么可能出错呢?特别是当算法在CPU上工作时?
StackExchange.Redis 是否有能力在缓存项过期后执行回调?就像 Microsoft.Practices.EnterpriseLibrary.Caching 中的 ICacheItemRefreshAction
[Serializable]
private class CacheEventHandler : ICacheItemRefreshAction
{
public void Refresh(string key, object expiredValue, CacheItemRemovedReason removalReason)
{
// Item has been removed from cache. Perform desired actions here, based upon
// the removal reason (e.g. refresh the cache with the item).
ResetStaticData();
}
}
Run Code Online (Sandbox Code Playgroud) 我正在从一个教程中学习TPL(async/await),我尝试使用控制台应用程序自己测试它.请不要被我的无知冒犯.我确定我在某处做错了 - 我写了下面的代码:
static void Main(string[] args_)
{
Task<int> task = ProcessNumber(25);
Console.WriteLine(string.Format("{0}: Waiting started...", DateTime.Now));
task.Wait();
Console.WriteLine(string.Format("{0}: Waiting ended...", DateTime.Now));
Console.WriteLine(task.Result);
Console.WriteLine("Press any key to terminate!");
Console.ReadLine();
}
static async Task<int> ProcessNumber(int i_)
{
Thread.Sleep(1000);
var integer = await IncrementNumber(i_ * 23);
return integer;
}
static async Task<int> IncrementNumber(int j_)
{
Thread.Sleep(6000);
return (j_ + 23) / 23;
}
Run Code Online (Sandbox Code Playgroud)
这是普通的C#控制台代码.我的问题是为什么我得到以下输出:
3/5/2015 5:22:37 PM: Waiting started...
3/5/2015 5:22:37 PM: Waiting ended...
26
Run Code Online (Sandbox Code Playgroud)
"等待开始"和"等待结束"之间是否应该有相当大的时间差距?
UPDATE
在答案之后,我发现Task.Delay(..)和Thread.Sleep(..)不一样,因为它们的工作方式完全不同.这是一个很好的链接,用一个例子来解释.
似乎将TPL视为多线程的另一个框架是错误的.所有的答案都对我有所帮助,所以我投票给了所有人.但是,我选择Jon的答案,因为它是最具说明性的,也是第一个出现的答案.谢谢大家!
我有一个查询rest API的方法,我在其中执行从JSON到对象的映射.由于我传递给此方法的查询字符串和对象类型始终必须匹配,因此我希望将查询字符串包含为静态字符串.
public class Root
{
public static string Query;
}
public class RootObject : Root, IRootObject
{
public D d { get; set; }
public static new string Query = "AccountSet";
}
public interface IRootObject
{
D d { get; }
}
public class RestClass
{
public void Connect<T>() where T : Root, IRootObject
{
T.Query <-- fails (not actual code. Just to show my problem)
}
}
Run Code Online (Sandbox Code Playgroud)