0

I'm extending in my class AsyncTask and I have a context passed however from another activity. So I tried this:

        listview = (ListView) findViewById(R.id.listview1);

Error:

The method findViewById(int) is undefined for the type loadSomeStuff

I tried this also:

        listview = (ListView) ctx.findViewById(R.id.listview1);

Error:

The method findViewById(int) is undefined for the type Context

How can I get over this error?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

it is either View.findViewById() or Activity.findViewById().

try

listview = (ListView) ((Activity)ctx).findViewById(R.id.listview1);

Source

Boris Mocialov
  • 3,439
  • 2
  • 28
  • 55