Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old September 14th, 2010, 10:58 AM   #1 (permalink)
New Member
 
Join Date: Jun 2010
Posts: 11
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Default cursor not returning correct row position in ListView

Hello all, could you please help me look and this code and tell me what am doing wrong. I have a listview that is populated through a Cursor Adapter but when i click on a row, it returns back the row above it and not the target row clicked. and if i click on the first row, it just crashes with a "cursor out of bound exception". Here is the code:

Code:
public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
		
		 c = adapter.retrieveRow(rowId);
			
 Intent edit = new Intent(this,Item.class);
	edit.putExtra(DBAdapter.KEY_ID, rowId);
edit.putExtra(DBAdapter.NAME, c.getString(c.getColumnIndex(DBAdapter.NAME)));
edit.putExtra(DBAdapter.START_DATE, c.getString(c.getColumnIndex(DBAdapter.START_DATE)));
startActivityForResult(edit, ACTIVITY_EDIT);
}
and this is the database method that is being called:

Code:
public Cursor retrieveRow(long rowId) {
 String[] resultColumns = new String[] {NAME,START_DATE};
             Cursor row = db.query(true,DATABASE_TABLE, resultColumns, KEY_ID +"=" +rowId, null, null, null, null,null);
		 if(row != null){
	            row.moveToFirst();
		 }
		  return row;
	  }
i have tried changing it to a OnListItemSelected() but nothing happens.I am using the new view and bind view method on the cursor adapter. Please Help.

motoko is offline  
Last edited by motoko; September 14th, 2010 at 11:45 AM.
Reply With Quote
Sponsors
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remember listview position and selection kaliki Application Development 4 September 7th, 2011 06:38 PM
Cursor for ListView has more than 1 MB Markus Taubek Application Development 0 January 12th, 2011 09:07 AM
How position cursor in text box? DonSz Samsung Fascinate 4 September 18th, 2010 08:59 AM
showing cursor data in a listview kitty Application Development 0 February 4th, 2010 01:01 AM



All times are GMT -5. The time now is 11:33 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo