私はListView
mysql dbからデータを取得することによって入力されたListView
...データベースからの3つの値を含んでいます...
- 名前
- カテゴリー
- 位置
これらの値を next に渡したいと思いますActivity
。だから私は使った
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
String items = parent.getItemAtPosition(position).toString();
Intent intent = new Intent();
intent.setClass(mapping, CheckIn.class);
intent.putExtra("name", items);
startActivity(intent);
}
});
しかし、配列 {name = xxx 、category = asdasd 、position = ddxxddxx} を生成します
2番目Activity
に、その指定された名前についてユーザーのコメントを取得し、それを別のテーブルに挿入したいと考えています。配列でこれを行う方法は?
完全なコード
try {
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setSoTimeout(params, 0);
HttpClient httpClient = new DefaultHttpClient(params);
// prepare the HTTP GET call
HttpGet httpget = new HttpGet("http://hopscriber.com/place.php");
// get the response entity
HttpEntity entity = httpClient.execute(httpget).getEntity();
if (entity != null) {
// get the response content as a string
String response = EntityUtils.toString(entity);
// consume the entity
entity.consumeContent();
// When HttpClient instance is no longer needed, shut down the
// connection manager to ensure immediate deallocation of all
// system resources
httpClient.getConnectionManager().shutdown();
// return the JSON response
ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();
JSONArray jsonArray = new JSONArray(response);
if (jsonArray != null) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject object = (JSONObject) jsonArray.get(i);
HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_Name, object.getString("name"));
map.put(TAG_Category, object.getString("category"));
contactList.add(map);
}
}
ListAdapter adapter = new SimpleAdapter(this, contactList,
R.layout.menu_list_row, new String[] { TAG_Name,
TAG_Category }, new int[] { R.id.LR_Name,
R.id.LR_date });
list.setAdapter(adapter);
}
} catch (Exception e) {
e.printStackTrace();
}
// Launching new screen on Selecting Single ListItem
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
String items = parent.getItemAtPosition(position).toString();
Intent intent = new Intent();
intent.setClass(mapping, CheckIn.class);
intent.putExtra("name", items);
startActivity(intent);
}
});
}