Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid get different id on listview item
    text
    copied!<p>I have a little problem sending the right id to another activity as extra.I'm getting id from database which I'm sending to the new activity so I can get the right data. But the problem is that my code is sending only the last id,which is on arraylist. How can I fix that? </p> <p>Here is the code I'm using :</p> <pre><code>for(cursorTitle.move(0); cursorTitle.moveToNext(); cursorTitle.isAfterLast()) { if (vf != null) { vf.removeAllViews(); } text = cursorTitle.getString(cursorTitle.getColumnIndex("title")); cardsCount = cursorTitle.getString(cursorTitle.getColumnIndex("cardsCount")); collId = Integer.parseInt(cursorTitle.getString(cursorTitle.getColumnIndex("objectId"))); Log.i("CollID","Collection ID : "+collId); b = BitmapFactory.decodeFile("/sdcard/7073d92dce10884554d7e047f1c51cb6.jpg", null); array = new ArrayList&lt;Integer&gt;(); array.add(collId); vf = new ViewFlipper(MyCollectionList.this); myListView = new ListView(MyCollectionList.this); hm = new HashMap&lt;String, Object&gt;(); hm.put(IMAGE, b); hm.put(TITLE, text); hm.put(CARDS_COUNT, cardsCount +" Stampii"); items.add(hm); final SimpleAdapter adapter = new SimpleAdapter(MyCollectionList.this, items, R.layout.main_listview, new String[]{TITLE, CARDS_COUNT, IMAGE}, new int[]{ R.id.main_name, R.id.main_info, R.id.main_img}); myListView.setAdapter(adapter); myListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) { Intent previewMessage = new Intent(getParent(), MyCollectionId.class); previewMessage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); TabGroupActivity parentActivity = (TabGroupActivity)getParent(); previewMessage.putExtra("collection_id", array.get(position)); parentActivity.startChildActivity("MyCollectionId", previewMessage); } }); } </code></pre> <p>Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload