我有一个活动,并且我有一个班级.
text=new Dynamictext(...);
text.setText("txt");
Run Code Online (Sandbox Code Playgroud)
在我的DynamicText java中,我有这样的代码:
public void setText(String text) {
this.text=text;
new asyncCreateText().execute();
//this.createText(text);
}
//private Handler handler = new Handler();
private class asyncCreateText extends AsyncTask<Void, Void, Void>
{
@Override
protected Void doInBackground(Void... unused) {
return null;
}
@Override
protected void onPostExecute(Void unused) {
}
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
ERROR/AndroidRuntime(5176):引起:java.lang.RuntimeException:无法在未调用Looper.prepare()的线程内创建处理程序
我该如何处理这个错误?
ERROR/AndroidRuntime(5370): java.lang.ExceptionInInitializerError
ERROR/AndroidRuntime(5370): at com.l.start.DynamicText.setText(DynamicText.java:125)
ERROR/AndroidRuntime(5370): at com.l.start.OpenGLRenderer.initfonts(OpenGLRenderer.java:168)
ERROR/AndroidRuntime(5370): at com.l.start.OpenGLRenderer.init(OpenGLRenderer.java:119)
ERROR/AndroidRuntime(5370): at com.l.start.OpenGLRenderer.onSurfaceChanged(OpenGLRenderer.java:90)
ERROR/AndroidRuntime(5370): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1120)
ERROR/AndroidRuntime(5370): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
ERROR/AndroidRuntime(5370): Caused by: java.lang.RuntimeException:
Can't create handler inside thread that …Run Code Online (Sandbox Code Playgroud) 如果我对这条线的内部运作的理解是正确的:
public int MyInt { get; set; }
Run Code Online (Sandbox Code Playgroud)
然后在幕后做这个:
private int _MyInt { get; set; }
Public int MyInt {
get{return _MyInt;}
set{_MyInt = value;}
}
Run Code Online (Sandbox Code Playgroud)
我真正需要的是:
private bool IsDirty { get; set; }
private int _MyInt { get; set; }
Public int MyInt {
get{return _MyInt;}
set{_MyInt = value; IsDirty = true;}
}
Run Code Online (Sandbox Code Playgroud)
但我想写一些类似于:
private bool IsDirty { get; set; }
public int MyInt { get; set{this = value; IsDirty = true;} }
Run Code Online (Sandbox Code Playgroud)
哪个不起作用.事情是我需要做的一些对象,IsDirty上有几十个属性,我希望有一种方法可以使用auto getter/setter,但是当字段被修改时仍然设置IsDirty.
这是可能的,还是我只需要让自己在我班级中增加三倍的代码?
我正在使用Savon为SOAP服务编写Ruby接口.它似乎正在工作,但我在命令行上出现了几个DEBUG消息
D, [2011-02-15T16:33:32.664620 #4140] DEBUG -- : HTTPI tried to use the httpclient adapter, but was unable to find the library in the LOAD_PATH. Falling back
using the net_http adapter now.
D, [2011-02-15T16:33:32.820863 #4140] DEBUG -- : HTTPI executes HTTP POST using the net_http adapter
D, [2011-02-15T16:33:32.664620 #4140] DEBUG -- : HTTPI tried to use the httpclient adapter, but was unable to find the library in the LOAD_PATH. Falling back
using the net_http adapter now.
D, [2011-02-15T16:33:32.820863 #4140] DEBUG -- …
好吧,我有一个类型的时间格式:2011-02-16T01:25:50 + 04:00
我想从字符串的末尾去掉+04:00.怎么做?
我正在使用此函数将时间戳从mysql转换为ISO 8601格式:
$timeagotime = date('c',strtotime($row['created_at']));
Run Code Online (Sandbox Code Playgroud)
其中$ timeagotime包含的值:2011-02-16T01:25:50 + 04:00
我在shell中使用过这个查询.它工作正常.如果我在php中使用它,它会显示一个错误
<?php
$m = new Mongo();
$db = $m->foo;
$collection = $db->base;
$query = array( "ro" => '/^a/' );
$cursor = $collection->find($query);
foreach ($cursor as $obj) {
echo $obj["ro"] . "<br/>";
}
Run Code Online (Sandbox Code Playgroud)
我不确定,会db.base.find({"ro": /^a/}).limit(10);在php中查询工作吗?
我正在尝试根据产品的类别将product_type添加到我的Magento Google Base输出中,但我似乎无法做到.我有以下代码:
// Get categories from product to include as product_type
$categoryIds = $object->getCategoryIds();
foreach($categoryIds as $categoryId) {
$category = Mage::getModel('catalog/category')->load($categoryId);
$this->_setAttribute('product_type', $category->getName(), 'text' );
}
Run Code Online (Sandbox Code Playgroud)
问题是它返回所有类别,而不仅仅是产品所在的类别.任何人都有解决方案吗?
我提供了这个提供叠加CSS的想法,作为另一个问题的答案.我以前没有想过使用这种类型的语法,但我想不出可能与使用它有关的任何问题.
据我所知,这是有效的 - 如果可以接受,我认为它提供了一种创新的解决方案 - 但我不认为它经常使用.
有人可以向我解释为什么它可能会很糟糕吗?
.ui-widget-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #444;
/* add some opacity here */
}
Run Code Online (Sandbox Code Playgroud) 我在C中看到了一些关于实现GC的帖子,有些人说这是不可能的,因为C是弱类型的.我想知道如何在C++中实现GC.
我想要了解如何做到这一点.非常感谢你!
这是我朋友告诉我的彭博采访问题.那时他做得很糟糕.我们想知道您对此的看法.
几年前,我从Windows切换到Linux,以获得更轻量和稳定的桌面环境.它运行良好,但我有足够的Linux问题考虑另一个变化.具体来说,我正在寻找系统库中更好的稳定性.
我使用Debian Unstable(argh ...... 我的意思是测试),因为我需要跟踪某些Linux应用程序的开发.由于它们处于积极开发阶段,我预计会偶尔出现漏洞.我的问题是基本系统实用程序中断的频率,如hdparm或halevt.在过去的一年中,每次更新系统或进行全新安装时,都会破坏一些不同的实用程序.
最好的替代品似乎是FreeBSD和Solaris.(Solaris可供开发使用,这是我所关心的).我在这里问哪个更适合我的使用和/或他们是否有足够的自己的问题,我会更好地坚持使用Linux.
我的用法:
Java开发,编程风格是独立于系统的桌面应用程序,主要针对Windows和OS X的目标用户
虚拟化以在各种操作系统上运行应用程序
一般的destop东西:文字处理,网络,音乐
不用作服务器
到目前为止,似乎是:
FreeBSD Pro文档,社区,简洁设计,广泛的端口Con Java支持
Solaris Pro Java和虚拟化支持Con 见FreeBSD pro的东西
使用Python,我可以使用'in'运算符进行set操作,如下所示:
x = ['a','b','c']
if 'a' in x:
do something
Run Code Online (Sandbox Code Playgroud)
C#中的等价物是什么?