1

i have an onitemclicklistener() implemented in my listview that shows all my database info

onitemclick((AdapterView<?> parent, View viewClicked, int position,
                    long bezoeknummer)

shown snippet of code returns me the first column value of that specific database row.

how can i make it return the 2nd column of that database row?

i tried already to make my cursor query to read the desired (2nd column value) as _id instead of my first row value but then my program crashes

edit,

i have following code for the onitemclick

private void herkenlijstklik() {
    ListView bezoelijst = (ListView) findViewById(R.id.listViewAbezoe); 
    bezoelijst.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View viewClicked, int position,
                long bezoeknummer) {
            Log.i("herkenlijstklik", "nummer gepaseerd door onitemclick, zou moeten hetzelfde zijn als bezoeknummer = " + bezoeknummer);

        }
    });

my cursor for my listview is formed as shown below out of my database

public Cursor leesallegegevens() {
            String waar = null;
            Cursor c =  onzedatabase.query(true, databasetabel, allekolommen, 
                                waar, null, null, null, null, null);
            if (c != null) {
                c.moveToFirst();
            }
            Log.i("cursor leesallegegevens", c.toString());
            return c;
        }

to ask again my question:

my database exists of multiple columns, the function Onitemclick() returns me the first column of that database what i my variable called long bezoeknummer to return is in the 2nd column

as the code is shown i do not have any errors in the logcat, only the wrong value returned

please help me how to return the desired value, please do not hesitate to ask more questions if necesary

keuninkske
  • 61
  • 9

1 Answers1

0

Long time ago i solved this prob in the meanwhile. As i remember i placed the variable i wanted to read at first place in the query for the adapter So: first i had string [] allekolommen = (recnum, bezoeknummer, ....)

After changing that to: string [] allekolommen = (bezoeknummer, recnum,....) Everything worked out for me

Ps: not completely sure anymore if that was complete solution

keuninkske
  • 61
  • 9