TextView中的ListView来自方法(非主线程UI)

时间:2013-05-29 11:56:00

标签: android multithreading listview

我想在一个方法中从主线程外部创建一个列表。但是编译器告诉我setListAdapter是未定义的。我做错了什么?

public void getVenues() {

        AsyncHttpClient client = new AsyncHttpClient();
        client.get(getQUERY_4SQ(), null, new JsonHttpResponseHandler() {

            @Override
            public void onFinish() {
                // TODO Auto-generated method stub
                super.onFinish();
                runOnUiThread(new Runnable() {
                    public void run() {
                        makeToast("Charged Categories", 1);
                    }
                });

                runOnUiThread(new Runnable() {
                    public void run() {
                        // storing string resources into Array
                        String[] name_venues;
                        for(int i = 0; i < listVenues.size(); i++){
                            name_venues[i] = listVenues.get(i).getName();
                        }

                        // Binding resources Array to ListAdapter
                        MainActivity.this.setListAdapter(new ArrayAdapter<String>(MainActivity.this, R.layout.list_venues, R.id.venueListUI, name_venues));

                    }
                });
            }

0 个答案:

没有答案