Assigning ID to a Row in an Android ListView -


I have a ListView when an item on the ListView is tapped, so it loads a SubView I can list each of the ListView I want to specify an ID for the line, so I can pass that ID with SubView. How do I specify a specific ID for each row in the ListView?

Here's what I'm currently loading ListView:

  setListAdapter (New ArrayEptter  (This, R.Lay Out .list_list, merchant));  

Here's how I solved the problem: I've got Employee Associates and Employees' names Meet with the local SQL Database, then I made an array list of the names and created an array list of employee Idri at the same time. In this way, the employee identifier [0] employee names will match with [0], the employee will match the IRAA [1] employee name Ore [1], etc. Etc.

Once the ArrayLists were created, I fed the names of the nameserver in ListView.

Later, onListItemClick, I will leave behind the selected ListView row's position. This 'position' array will be corrospond for the position in the list - thus, if I select the first line in ListView, The situation will be zero, and the employeeNameArray [0] corresponds to the employee IdArray [0]. I grab the corrupt entry from the employee IDEER and proceed with the next activity using PutXtra.

  The public class provides the MyFirstDatabase list extension {ArrayList & lt; String & gt; EmployeeIdArray = New Arrestist & lt; String & gt; (); // Employee ID / ** list when activity is created first * / @ Override Crate on Public Zero (Bundle Saved Instantstate) {Super. Contents (Saved Instantstate); // Open database database SQLiteDatabase; Db = openOrCreateDatabase ("mydb.db", SQLiteDatabase.CREATE_IF_NECESSARY, blank); Db.setVersion (1); Db.setLocale (Locale.getDefault ()); Db.setLockingEnabled (true); // database query cursor cur = db.query ("employee", blank, blank, weak, empty, blank, "employee_lostaman"); Cur.moveToFirst (); // When the DB results start up, go to ArrayList & lt; String & gt; EmployeeNameArray = New Arrestist & lt; String & gt; (); // start mArrayList while (cur.isAfterLast () == incorrect) {employeeNameArray.add (cur.getString (1)); // Add the employee's name to the name, your employee id.r.r. (cur.getString (0)); // idArray cur.moveToNext (); Add Employee ID; // Set the next result in the cursor; Cur.close (); // Close the cursor / name list list set in list adapter (new array adapter & lt; string & gt; (this, r.lit.list_litem, employee name array)); ListView lv = getListView (); Lv.setTextFilterEnabled (true); } Secure void onListItemClick (ListView L, See V, Final Integer Status, Long ID) {super.onListItemClick (L, V, Status, ID); MyIntent = new intent (this, SubView.class); // When a line is used, SubView.class integer selectionIDID = integer.center (employee IDARR.AT (position)); Get the value from // Employer IdArray corrosponds for the 'position' of the selected row myIntent.putExtra ("ROWID", selectID); // select startActivityForResult (myIntent, 0) Add selectID; // display subView.class}}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -