iT邦幫忙

0

android listView item事件

2636 2013-03-31 21:27:054824 瀏覽
  • 分享至 

  • xImage

舉例我點擊第一個item,我要進入另一個畫面,但另一個畫面的資料是這個item的詳細內容
請幫幫我~

public void stationListSetup() {
try {
List<Map<String, Object>> listMap = new ArrayList();
URL url = new URL(MmyContext.URLMYEATT);
// URL url = new URL(MYBICK);
conn = (HttpURLConnection) url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
String line;
StringBuilder sb = new StringBuilder();

while ((line = in.readLine()) != null) {
sb.append(line);
}
JSONArray arr = new JSONArray(sb.toString());
for (int i = 0; i < arr.length(); i++) {
JSONObject obj = (JSONObject) arr.get(i);
Map<String, Object> map = new HashMap<String, Object>();
Double thxx = obj.optDouble("xx");
Double thyy = obj.optDouble("yy");
Double testxx = 121.51557;
Double testyy = 25.04655;

if ((Math.abs(lonnxx - thxx) + Math.abs(lonnyy - thyy)) < 0.03) {
map.put("txtName", obj.opt("name"));
map.put("txtRent", obj.opt("tel"));
map.put("txtPark", obj.opt("address"));
listMap.add(map);
}
}
ListView listView = (ListView) findViewById(R.id.listView1);
listView.setAdapter(new SimpleAdapter(this, listMap,
R.layout.listroe, new String[] { "txtName", "txtRent","txtPark"},
new int[] { R.id.store_name,R.id.store_phone, R.id.store_address }));
//添加點擊
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
startActivity(new Intent(ListhostActivity.this,StoreContent.class));
}
});
} catch (Exception e) {
Log.e("jsontolist", "", e);
}
}

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2

從startActivity那邊開始

&lt;pre class="c" name="code">
    Intent intent = new Intent(ListhostActivity.this,StoreContent.class);

    Bundle bundle = new Bundle();
    bundle.putString("Name", Name);

    intent.putExtras(bundle);
 
    startActivity(intent);
2636 iT邦新手 5 級 ‧ 2013-04-04 01:53:35 檢舉

我照者這樣嘗試,結果這段
bundle.putString("Name", Name);
Name是無效的,
第一個name代表的是?
第二個name代表的是?
可以再詳細一些嗎,跟接收端的class要怎麼接收?

我要發表回答

立即登入回答