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?
}
結果を適切に構造化されたデータにしてリストをリセットすることはできますが、それがどのように行われるかはわかりません。誰か助けてもらえますか?:)