我想做一件简单的事情:定义一个drawable,它与系统状态按下的背景颜色具有非常相似的背景颜色.我在res/drawables/my_drawable.xml中这样做:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_selected="true">
<color android:color="?android:attr/colorPressedHighlight"/>
</item>
<item android:state_selected="false">
<color android:color="@color/section_list_background"/>
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
我总是得到:
java.lang.UnsupportedOperationException: Cant convert to color: type=0x2
Run Code Online (Sandbox Code Playgroud)
有线索吗?
问候
它是如何工作的?我有如下布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/search_form_fragment"
android:name="FragmentClass"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<fragment
android:id="@+id/result_list_fragment"
android:name="FragmentClass"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
注意第二个片段有android:visibility="gone",实际上它在屏幕上不可见.但是这段代码:
boolean bothVisible = firstFrag.isVisible() && secondFrag.isVisible();
Run Code Online (Sandbox Code Playgroud)
回报true,这是我没想到的.我想知道使用android:visibility是否正确,因为我在文档中找不到任何相关信息.
最近我正在调整我的一些机器学习管道.我决定利用我的多核处理器.我用param运行交叉验证n_jobs=-1.我也对它进行了分析,对我来说是多么的惊喜:最重要的功能是:
{method 'acquire' of 'thread.lock' objects}
Run Code Online (Sandbox Code Playgroud)
由于我的操作,我不确定这是不是我的错Pipeline.所以我决定做一个小实验:
pp = Pipeline([('svc', SVC())])
cv = GridSearchCV(pp, {'svc__C' : [1, 100, 200]}, jobs=-1, cv=2, refit=True)
%prun cv.fit(np.random.rand(1e4, 100), np.random.randint(0, 5, 1e4))
Run Code Online (Sandbox Code Playgroud)
输出是:
2691 function calls (2655 primitive calls) in 74.005 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
83 43.819 0.528 43.819 0.528 {method 'acquire' of 'thread.lock' objects}
1 30.112 30.112 30.112 30.112 {sklearn.svm.libsvm.fit}
Run Code Online (Sandbox Code Playgroud)
我想知道这种行为的原因是什么.如果有可能加快它的速度.
目前,我正在处理一个非常适合我的内存的巨大数据集,因此我使用np.memmap。但是在某些时候,我必须将我的数据集分为训练和测试。当我想np.memmap使用一些索引数组切片时,我发现了这种情况:(下面可以找到代码和内存分配)
Line # Mem usage Increment Line Contents
================================================
7 29.340 MB 0.000 MB def my_func2():
8 29.340 MB 0.000 MB ARR_SIZE = (1221508/4,430)
9 29.379 MB 0.039 MB big_mmap = np.memmap('big_mem_test.mmap',shape=ARR_SIZE, dtype=np.float64, mode='r')
10 38.836 MB 9.457 MB idx = range(ARR_SIZE[0])
11 2042.605 MB 2003.770 MB sub = big_mmap[idx,:]
12 3046.766 MB 1004.160 MB sub2 = big_mmap[idx,:]
13 3046.766 MB 0.000 MB return type(sub)
Run Code Online (Sandbox Code Playgroud)
但是,如果我想进行连续切片,我会使用以下代码:
Line # Mem usage Increment Line Contents
================================================
15 29.336 …Run Code Online (Sandbox Code Playgroud) 我想创造i386环境QEMU环境chroot \n我使用的是 Raspberry Pi ver B,但我想使用哪个版本应该不重要。
到目前为止我做了:
\n\napt-get install qemu qemu-user qemu-user-static binfmt-support debootstrap binutils\nRun Code Online (Sandbox Code Playgroud)\n\n然后我将chroot目录安装到/tmp/mnt并运行:
sudo debootstrap --foreign --arch i386 buster ./ http://deb.debian.org/debian/\nRun Code Online (Sandbox Code Playgroud)\n\n然后我安装了:
\n\nmount -t sysfs /sys /tmp/mnt/sys/\nmount -t proc /proc /tmp/mnt/proc/\nmount \xe2\x80\x93bind /dev /tmp/mnt/dev/\nmount \xe2\x80\x93bind /dev/pts /tmp/mnt/dev/pts/\nmount \xe2\x80\x93bind /dev/shm /tmp/mnt/dev/shm/\nRun Code Online (Sandbox Code Playgroud)\n\n现在当我尝试运行第二阶段时debootstrap:
sudo chroot ./ ./debootstrap/debootstrap --second-stage\nRun Code Online (Sandbox Code Playgroud)\n\n我收到以下错误消息:
\n\nW: Failure trying to run: /sbin/ldconfig\nW: See //debootstrap/debootstrap.log for …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我需要从Android AsyncTask的onPostExecute()方法访问我的Activity中的方法
我有2个活动都包含一个常用方法如下:
(1)Activity1 - > refreshUI()
(2)Activity2 ----> refreshUI()
我有一个AsyncTask调用GetDataAsyncTask(Activity a )将调用活动作为参数
现在从我的活动1我将打电话给新的GetDataAsyncTask(Activity1.this).execute.
与我的活动2相同,我会打电话给新的GetDataAsyncTask(Activity2.this).execute.
我的AsyncTask如下:
public class GetDataAsyncTask extends AsyncTask<String ,Void , String> {
public Activity context;
public PostAsyncTaskHelper(Activity c) {
context = c;
}
protected String doInBackground(String... arg0) {
// Webservice calls
}
protected void onPostExecute(String result) {
if(result.equals("qq")) {
//Where I am not able to access refreshUI()
//method of any one of my activities
context.refreshUI()
}
} …Run Code Online (Sandbox Code Playgroud) android android-widget android-emulator android-intent android-layout