上下文和自定义适配器

时间:2013-01-03 20:04:23

标签: android-asynctask this adapter android-context

我需要Asynctask和自定义适配器的帮助。 我有一个asynctask通过解析获取数据。然后我必须将它们放在ListView中。 我创建了一个自定义适配器,但我对上下文有一些问题。我确信这有一个非常简单的解决方案,但我无法理解实际上下文是什么! eclipse中说明了这个问题:

 protected void onPostExecute(final List<String> list) {
        ListView listView = (ListView)findViewById(R.id.listavvisi);

        CustomAdapter adapter = new CustomAdapter(**this**, R.layout.rowcustom, list);
        listView.setAdapter(adapter);

我将列表传递给customadapter

public class CustomAdapter extends ArrayAdapter<Avviso> {
private Context context;

  public CustomAdapter(**Context** **context**, int textViewResourceId, List<Avviso> Strings) {
        super(context, textViewResourceId, Strings);
}

调用New Customadapter...时我需要什么上下文

1 个答案:

答案 0 :(得分:1)

我回答我自己的问题。 所以,我不得不使用“javaclass.this”而不是“context”