无法在Asynctask Android、java中调用视图

无法在Asynctask Android、java中调用视图,java,android,view,android-asynctask,Java,Android,View,Android Asynctask,我试图从Asynctask类中的另一个类调用视图,但它似乎不起作用 这是我的地址 private class parseSite extends AsyncTask<String, Void, List<Integer>> { protected List<Integer> doInBackground(String... arg) { List<Integer> output = new ArrayList<Intege

我试图从Asynctask类中的另一个类调用视图,但它似乎不起作用

这是我的地址

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);

    }
}

我不明白它为什么不能调用视图。

假设您打算以某种方式扩展
上下文,例如通过扩展
活动,并且
解析站点
是在
图形中定义的,请进行以下更改:

View chartView = salesView.getView(graph.this);
在原始代码中,
指的是
解析站点
,它不扩展
上下文
(并且不像您可能想要的那样指的是
图形


作为旁注,在典型的Java风格的类中,应该使用大写字母命名,即
Graph
而不是
Graph

我认为问题在于您试图从创建它的其他线程访问视图。通常的方法是使用
runOnUiThread()


…错误发生在“View chartView=salesView.getView(this);”行View chartView=salesView.getView(this);在上面的代码中,“this”指的是AsyncTask实例,而不是上下文。也许你想写ParentActivity。这是吗?你忘了发布你得到的错误/异常啊,我没有在图中定义寄生虫。你建议我怎么做?将类移动到graph。您可能希望也可能不希望将其设置为静态。谢谢,非常感谢!
View chartView = salesView.getView(graph.this);
(activity).runOnUiThread(new Runnable() {
     public void run() {

 //call anything to your View objects

    }
});