0
protected void onPostExecute(String s) {

   veriAdaptoru=new ArrayAdapter<String>
      (this, android.R.layout.simple_list_item_1, android.R.id.text1, a);
   liste=(ListView)findViewById(R.id.listView1);
   liste.setAdapter(veriAdaptoru);      
}

i have to write this code but in this part i get error

(veriAdaptoru=new ArrayAdapter<String>
           (this, android.R.layout.simple_list_item_1, android.R.id.text1, a);)

1 Answer 1

2

The problem is in new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, android.R.id.text1, a); you must load context from Activity, but if you write this in onPostExecute it is another. Make in you Activity class some variable

Context context = MyActivity.this;

if your AsyncTask is in another class - create constructor and pass context from Activiy in it. and then you can do

 (context, android.R.layout.simple_list_item_1, android.R.id.text1, a);`
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.