后,用一个ArrayAdapter ListView控件重置我使用的是ListAdapter填充这样一个ListView:如何获取数据
static final String[] PROBLEMS = new String[] {"one", "two", "three" };
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.my_problems, PROBLEMS));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
之后,我想提出我的服务器远程调用以获取更多数据该列表与一个AsyncTask调用,并且当我从服务器获取数据时,我不知道如何填充和重置ListView。到目前为止,我有这样的事情:
@Override
protected void onPostExecute(String result)
{
// Unwrap the stuff from the JSON string
String problem_title = null;
String problem_id = null;
try
{
JSONArray obj = new JSONArray(result);
JSONObject o = obj.getJSONObject(0);
Log.d("Title: " , "" + o.getString("problem_title"));
Log.d("id: " , "" + o.getString("problem_id"));
problem_title = o.getString("problem_title");
problem_id = o.getString("problem_id");
}
catch (Exception e)
{
}
// Now not sure what to do :)
// How do I reset the list that I had set up above?
}
我可以使结果到适当的结构化数据重置列表中,但不知道如何做到这一点。有人可以帮忙吗? :)
现在让我说......我会告诉你如何去:) – GeekedOut 2012-03-10 15:22:18
啊好吧,这是编译!谢谢! – GeekedOut 2012-03-10 15:27:12
没问题,祝你好运 – 2012-03-10 15:30:10