BaseAdapter class wont setAdapter inside Asynctask - Android

a 夏天 提交于 2019-11-27 09:51:28

Have you checked if the View v that you return from your getView() method is null? Catching Exception catches all exceptions. Not really helpful in my opinion. What's happening here is that you have not initiated Context ctx_invitation. You should do this in the constructor. Now, since ctx_invitation is null, it causes a NullPointerException which is caught by the catch block. and View v remains null.

Change the constructor for CreateCommentLists:

public CreateCommentLists(String[] comments, String[] usernames, String[] numbers, DashboardActivity context)
        {
            super();

            listComments = comments;
            listNumbers = usernames;
            listUsernames = numbers;
            ctx_invitation = context;
        }

Change the following as well:

CreateCommentLists mycmlist = new CreateCommentLists(comments, usernames, numbers, DashboardActivity.this);

I hope this might be help,

onPostExecute include (Inside AsyncTask)

ExampleAdapter sectionedAdapter = new EfficientAdapter(ClassInfoThread.this,getBaseContext()); listView.setAdapter(sectionedAdapter);

and in your adapter class add this constructor

public ExampleAdapter(ExampleThread exampleThread,Context context) { mInflater = LayoutInflater.from(context); }

good luck.

Nandakishore P

Now ctx_invitation is never assigned a value. You probably need a constructor to assign value to ctx_invitation.

Selecsosi

Googling around, looking at this question looks like you might be returning a null view from your adapter's getView method. Try tossing some breakpoints into the getView method and figure out where you are returning a null view.

Also, where are you storing the reference to the ctx_invitation in your BaseAdapter.

In the constructor you might want to pass that in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!