Use Simple cursor adapter insted of array adapter... Check http://thinkandroid.wordpress.com/2010/01/09/simplecursoradapters-and-listviews/
On Mon, Sep 19, 2011 at 4:54 PM, Bishan <[email protected]> wrote: > Got java.lang.ClassCastException: java.lang.String in line 78 > > (code in line 78 is cursor = (Cursor) parent.getItemAtPosition(position);) > > what is the issue ? > file attached. > > On Mon, Sep 19, 2011 at 11:42 AM, Krishna Prasad < > [email protected]> wrote: > >> did u get your values from db correctly? >> >> >> On Mon, Sep 19, 2011 at 11:21 AM, Bishan <[email protected]> wrote: >> >>> i got this exception, >>> >>> java.lang.ClassCastException: android.widget.ArrayAdapter >>> >>> for below code. >>> >>> SimpleCursorAdapter simpleCursorAdapter = (SimpleCursorAdapter) >>> parent.getAdapter(); >>> >>> On 9/19/11, Bishan <[email protected]> wrote: >>> > thanx Krishna. i'll check this. >>> > >>> > On 9/19/11, Krishna Prasad <[email protected]> wrote: >>> >> final int id = cursor.getint(idColIndex ); >>> >> >>> >> just check the value using logcat whether it is getting or not >>> >> >>> >> On Mon, Sep 19, 2011 at 10:57 AM, Krishna Prasad < >>> >> [email protected]> wrote: >>> >> >>> >>> id means the String variable where u save the cursor.colum value. >>> >>> >>> >>> >>> >>> On Mon, Sep 19, 2011 at 10:53 AM, Bishan <[email protected]> wrote: >>> >>> >>> >>>> bundle.putString("any name",Id); >>> >>>> >>> >>>> what is the " Id " in above code ? >>> >>>> >>> >>>> On 9/19/11, Krishna Prasad <[email protected]> wrote: >>> >>>> > welcome.. >>> >>>> > >>> >>>> > On Mon, Sep 19, 2011 at 10:33 AM, Bishan <[email protected]> >>> wrote: >>> >>>> > >>> >>>> >> thanx Krishna :) >>> >>>> >> >>> >>>> >> On 9/19/11, Krishna Prasad <[email protected]> >>> wrote: >>> >>>> >> > @Override >>> >>>> >> > public void onItemClick(AdapterView<?> parent, View >>> >>>> >> > arg1, >>> >>>> >> > int >>> >>>> >> i, >>> >>>> >> > long l) { >>> >>>> >> > try { >>> >>>> >> > >>> >>>> >> > SimpleCursorAdapter simpleCursorAdapter = >>> >>>> >> > (SimpleCursorAdapter) parent >>> >>>> >> > .getAdapter(); >>> >>>> >> > final Cursor cursor = >>> >>>> >> simpleCursorAdapter.getCursor(); >>> >>>> >> > >>> >>>> >> > final int idColIndex = >>> >>>> cursor.getColumnIndex("_id"); >>> >>>> >> > >>> >>>> >> > Save the value in a variable and use bundles >>> >>>> >> > >>> >>>> >> > >>> >>>> >> > Bundle bundle = new Bundle(); >>> >>>> >> > bundle.putString("any name",Id); >>> >>>> >> > >>> >>>> >> > Intent intent = new Intent(first >>> >>>> >> > activity.this, >>> >>>> >> > second activity.class); >>> >>>> >> > intent.putExtras(bundle); >>> >>>> >> > startActivity(intent); >>> >>>> >> > >>> >>>> >> > On Mon, Sep 19, 2011 at 10:27 AM, Bishan <[email protected]> >>> >>>> >> > wrote: >>> >>>> >> > >>> >>>> >> >> I have wrote a program to get students names from database and >>> >>>> display >>> >>>> >> >> them, using ListActivity. and used OnItemClickListener to >>> click >>> >>>> >> >> on >>> >>>> >> >> each items. >>> >>>> >> >> >>> >>>> >> >> now i want to do, when i click on a student name, display >>> other >>> >>>> >> >> information of student (age, sex, address) on another screen. >>> >>>> >> >> >>> >>>> >> >> how could i do this? >>> >>>> >> >> >>> >>>> >> >> pls guide me. >>> >>>> >> >> >>> >>>> >> >> -- >>> >>>> >> >> You received this message because you are subscribed to the >>> >>>> >> >> Google >>> >>>> >> >> Groups "Android Developers" group. >>> >>>> >> >> To post to this group, send email to >>> >>>> >> [email protected] >>> >>>> >> >> To unsubscribe from this group, send email to >>> >>>> >> >> [email protected] >>> >>>> >> >> For more options, visit this group at >>> >>>> >> >> http://groups.google.com/group/android-developers?hl=en >>> >>>> >> > >>> >>>> >> > -- >>> >>>> >> > You received this message because you are subscribed to the >>> Google >>> >>>> >> > Groups "Android Developers" group. >>> >>>> >> > To post to this group, send email to >>> >>>> [email protected] >>> >>>> >> > To unsubscribe from this group, send email to >>> >>>> >> > [email protected] >>> >>>> >> > For more options, visit this group at >>> >>>> >> > http://groups.google.com/group/android-developers?hl=en >>> >>>> >> >>> >>>> >> -- >>> >>>> >> You received this message because you are subscribed to the >>> Google >>> >>>> >> Groups "Android Developers" group. >>> >>>> >> To post to this group, send email to >>> >>>> [email protected] >>> >>>> >> To unsubscribe from this group, send email to >>> >>>> >> [email protected] >>> >>>> >> For more options, visit this group at >>> >>>> >> http://groups.google.com/group/android-developers?hl=en >>> >>>> >> >>> >>>> > >>> >>>> > -- >>> >>>> > You received this message because you are subscribed to the Google >>> >>>> > Groups "Android Developers" group. >>> >>>> > To post to this group, send email to >>> >>>> [email protected] >>> >>>> > To unsubscribe from this group, send email to >>> >>>> > [email protected] >>> >>>> > For more options, visit this group at >>> >>>> > http://groups.google.com/group/android-developers?hl=en >>> >>>> >>> >>>> -- >>> >>>> You received this message because you are subscribed to the Google >>> >>>> Groups "Android Developers" group. >>> >>>> To post to this group, send email to >>> >>>> [email protected] >>> >>>> To unsubscribe from this group, send email to >>> >>>> [email protected] >>> >>>> For more options, visit this group at >>> >>>> http://groups.google.com/group/android-developers?hl=en >>> >>>> >>> >>> >>> >>> >>> >> >>> >> -- >>> >> You received this message because you are subscribed to the Google >>> >> Groups "Android Developers" group. >>> >> To post to this group, send email to >>> [email protected] >>> >> To unsubscribe from this group, send email to >>> >> [email protected] >>> >> For more options, visit this group at >>> >> http://groups.google.com/group/android-developers?hl=en >>> > >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Developers" group. >>> To post to this group, send email to [email protected] >>> To unsubscribe from this group, send email to >>> [email protected] >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >>> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

