logcat - Android String Resource not found Exception -



logcat - Android String Resource not found Exception -

so in app have edit text gets changed depending on click of button within list view. have used interface , custom adapter. app launches fine when seek click button app crashes , gives 'resource not found exception'. can help prepare error?

my main activity

package com.example.rory.dbtest; import android.app.activity; import android.content.intent; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.os.handler; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.baseadapter; import android.widget.button; import android.widget.edittext; import android.widget.listview; import android.widget.toast; import com.pinchtapzoom.r; import java.io.file; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import java.sql.sqlexception; public class myactivity extends activity implements myadapterinterface{ private customcursoradapter customadapter; public listview list1; com.example.rory.dbtest.dbadapter db = new com.example.rory.dbtest.dbadapter(this); public myactivity mmyactivity; //public edittext totalcost; //public edittext totallitres; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_my); list1 = (listview)findviewbyid(r.id.data_list); db.open(); mmyactivity = this; button addbtn = (button)findviewbyid(r.id.add); addbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent = new intent(myactivity.this, addassignment.class); startactivity(i); } }); button deletebtn = (button)findviewbyid(r.id.delete); deletebtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent = new intent(myactivity.this, delete.class); startactivity(i); } }); button updatebtn = (button)findviewbyid(r.id.update); updatebtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { intent = new intent(myactivity.this, update.class); startactivity(i); } }); seek { string destpath = "/data/data/" + getpackagename() + "/databases/assignmentdb"; file f = new file(destpath); if (!f.exists()) { copydb( getbasecontext().getassets().open("mydb"), new fileoutputstream(destpath)); } } grab (filenotfoundexception e) { e.printstacktrace(); } grab (ioexception e) { e.printstacktrace(); } new handler().post(new runnable() { @override public void run() { //log.d("test", "customadapter " + customadapter.tostring()); //log.d("test", "databasehelper " + databasehelper.tostring()); customadapter = new customcursoradapter(myactivity.this, db.getallrecords(), mmyactivity); list1.setadapter(customadapter); } }); } public void updateedittext(int value) { edittext myedittext = (edittext)findviewbyid(r.id.edit1); myedittext.settext(value); } private class dbadapter extends baseadapter { private layoutinflater minflater; //private arraylist<> @override public int getcount() { homecoming 0; } @override public object getitem(int arg0) { homecoming null; } @override public long getitemid(int arg0) { homecoming 0; } @override public view getview(int arg0, view arg1, viewgroup arg2) { homecoming null; } } public void copydb(inputstream inputstream, outputstream outputstream) throws ioexception { //---copy 1k bytes @ time--- byte[] buffer = new byte[1024]; int length; while ((length = inputstream.read(buffer)) > 0) { outputstream.write(buffer, 0, length); } inputstream.close(); outputstream.close(); } }

my custom adapter

package com.example.rory.dbtest; /** * created rory on 02/11/2014. */ import android.content.context; import android.database.cursor; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.button; import android.widget.cursoradapter; import android.widget.edittext; import android.widget.linearlayout; import android.widget.relativelayout; import android.widget.textview; import com.pinchtapzoom.r; public class customcursoradapter extends cursoradapter{ public int counter = 0; private myadapterinterface mmyinterface; public customcursoradapter(context context, cursor c, myadapterinterface myinterface) { super(context, c); this.context = context; this.mmyinterface = myinterface; } context context; @override public view newview(context context, cursor cursor, viewgroup parent) { // when view created first time, // need tell adapters, how each item layoutinflater inflater = layoutinflater.from(parent.getcontext()); view retview = inflater.inflate(r.layout.row, parent, false); homecoming retview; } public void bindview(view view, context context, cursor cursor) { // here setting our info // means, take info cursor , set in views textview textviewpersonname = (textview) view.findviewbyid(r.id.item1); textviewpersonname.settext(cursor.getstring(cursor.getcolumnindex(cursor.getcolumnname(1)))); final edittext edit1 = (edittext) view.findviewbyid(r.id.runningtotal); button plusbutton = (button) view.findviewbyid(r.id.plusbutton); plusbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { counter++; edit1.settext(integer.tostring(counter)); mmyinterface.updateedittext(counter); } }); final button minusbutton = (button) view.findviewbyid(r.id.minusbutton); minusbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { counter--; edit1.settext(integer.tostring(counter)); mmyinterface.updateedittext(counter); } }); } }

my logcat error

process: com.example.rory.dbtest, pid: 32185 android.content.res.resources$notfoundexception: string resource id #0xffffffff @ android.content.res.resources.gettext(resources.java:244) @ android.widget.textview.settext(textview.java:3888) @ com.example.rory.dbtest.myactivity.updateedittext(myactivity.java:112) @ com.example.rory.dbtest.customcursoradapter$2.onclick(customcursoradapter.java:66) @ android.view.view.performclick(view.java:4438)

the problem you're trying set int edittext needs string. simple solution alter line

myedittext.settext(value);

to this

myedittext.settext(string.valueof(value));

as pointed out 2 previous commenters.

android logcat

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -