AnnBnnCnnD 2013-01-18 03:32 采纳率: 0%
浏览 2031

在异步任务中无法调用view

在Asynctask类中调用另一个类的view,但是没成功,请帮忙。

异步任务:

private class parseSite extends AsyncTask<String, Void, List<Integer>> {

    protected List<Integer> doInBackground(String... arg) {
     List<Integer> output = new ArrayList<Integer>();
        try {
            htmlHelper hh = new htmlHelper(new URL(arg[0]));
            output = hh.htmlHelper(arg[0]);
        } catch (Exception e) {
            System.out.println("Error");
        }
        return output;
    }

    protected void onPostExecute(List<Integer> exe) {

        graph salesView = new graph();
        View chartView = salesView.getView(this);
        chartView.setLayoutParams(new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.FILL_PARENT, 1f));
        LinearLayout layout = (LinearLayout) findViewById(R.id.linearview);

        layout.addView(chartView, 0);

    }
}

activity的graph:

public class graph {

public View getView(Context context) (...etc.)

谢谢:-D

  • 写回答

2条回答

  • Billy_崔海斌 2013-01-18 06:16
    关注

    设置一个handler,当执行需要更改ui的时候,通过handler.sentMessage去通知handle里面去更改UI.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料