SimpleCursorAdapter是否在UI线程上运行

时间:2013-12-18 10:59:48

标签: java android

docs中提到了

SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to)

气馁,因为它会导致在应用程序的UI线程上执行Cursor查询 ..

但是没有提到下面的构造函数

SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags)

doSimpleCursorAdapter,第二个构造函数在UI线程上运行

1 个答案:

答案 0 :(得分:-1)

all Adapters works on UI Thread in android . if you wants to use from Non UI Thread use this 

runOnUiThread(new Runnable() {

@Override
        public void run() {
            list.setAdapter(adapter);
        }
});
or simply post a runnable to the UI thread:

view.post(new Runnable() {

    @Override
    public void run() {
        list.setAdapter(adapter);
    }

});