我创建了 ListView ,并且我能够静态填写列表(它工作得很好),但我无法动态填写,.. 在加载列表后使用提要推文之后什么都没有出现,这里是代码:
list = new ArrayList<String>();
arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, list);
listtwitt.setAdapter(arrayAdapter);
TwitAsyncTask twitAsync = new TwitAsyncTask();
twitAsync.execute();
}
@SuppressLint("NewApi")
private class TwitAsyncTask extends AsyncTask<Void, Void, Void>{
private ProgressDialog progressDialo;
@Override
protected void onPreExecute() {
progressDialo = ProgressDialog.show(SocialNetwork.this, "", "En cours...");
super.onPreExecute();}
@Override
protected Void doInBackground(Void... params) {
final Query query = new Query();
query.setQuery("%23morocco");
QueryResult result;
try {
result = twitter.search(query);
for (twitter4j.Status status : result.getTweets()) {
String stat = "@" + status.getUser().getScreenName() + ":" + status.getText() +":"+status.getGeoLocation() +":"+status.getCreatedAt();
list.add("tweet");
Log.i(""," tweeeeeeet"+stat);
Log.i("","list doInBack"+list.isEmpty());
}
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
progressDialo.dismiss();
arrayAdapter.clear();
arrayAdapter.addAll(SocialNetwork.list);
arrayAdapter.notifyDataSetChanged();
}
任何帮助:)