Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ArrayAdapter with Object and Get some data from that object
    primarykey
    data
    text
    <p>Im trying to make ListView using data from Array, but I need to get Id of clicked row (not shown in that row, but userd in creation of that product)</p> <p>Im using this class for object:</p> <pre><code>package com.example.raidplanner; public class RaidWpis { private int id; private int id_gildia; private String nazwa; private int schemat; private int data_zapis; private int data_start; private int opis; private int id_officer; private int nick_officer; private int typ; public RaidWpis(int id,String nazwa) { setNazwa(nazwa); setId(id); } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getNazwa() { return nazwa; } public void setNazwa(String nazwa) { this.nazwa = nazwa; } public String toString() { return this.nazwa; } public String toString2() { return this.id+" - "+nazwa; } } </code></pre> <p>And this code in Activity:</p> <pre><code>RaidWpis[] items = { new RaidWpis(1, "aaaa"), new RaidWpis(3, "bbbb"), new RaidWpis(6, "cccc"), new RaidWpis(11, "dddd"), new RaidWpis(17, "eeee"), }; mainListView = (ListView) findViewById( R.id.mainListView ); ArrayAdapter&lt;RaidWpis&gt; raidList = new ArrayAdapter&lt;RaidWpis&gt;(this, R.layout.simplerow, items); // Create ArrayAdapter using the raid list. mainListView.setAdapter(raidList); mainListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { String item = ((TextView)view).getText().toString(); Toast.makeText(getBaseContext(), item, Toast.LENGTH_LONG).show(); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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