I have a static class and I want to set a ListAdapter through the AsyncTask onPostExecute but it gives the error : nestedObject cannot be resolved to a type
static class(nested class) :
public static class DummySectionFragment extends ListFragment
{
public PostData[] listData;
public PostItemAdapter adapter;
//DownloadWebPageTask task = new DownloadWebPageTask();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
this.generateDummyData();
adapter = new PostItemAdapter(inflater.getContext(), android.R.layout.simple_list_item_1, listData);
setListAdapter(adapter);
//task.execute();
View rootView = inflater.inflate(R.layout.fragment_section_news, container, false);
return rootView;
}
private void generateDummyData()
{
PostData data = null;
listData = new PostData[10];
// sets a default value to Date,Title and URL
for (int i = 0; i < 10; i++)
{
data = new PostData();
data.postDate = "May 20, 2013";
data.postTitle = "Post " + (i + 1) + " Title: This is the Post Title from RSS Feed";
data.postThumbUrl = null;
listData[i] = data;
}
}
}
AsyncTask :
public static class DownloadWebPageTask extends AsyncTask<List<String>, Void, List<String>>
{
@Override
protected List<String> doInBackground(List<String>... urls)
{
FeedParser parser = FeedParserFactory.getParser();
messages = parser.parse();
List<String> titles = new ArrayList<String>(messages.size());
for (Message msg : messages)
{
titles.add(msg.getTitle());
}
return titles;
}
@Override
protected void onPostExecute(List<String> result)
{
MainActivity.DummySectionFragment nestedObject = new MainActivity.DummySectionFragment();
ArrayAdapter<String> adapter = new ArrayAdapter<String> (nestedObject.this,R.layout.fragment_section_nieuws, result);
nestedObject.this.setListAdapter(adapter);
}
}
I'm trying to do this in a ListFragment instead of a ListActivity