Is there a way to do this? My specific purpose is that I am trying to populate a label from an edittext within my list that is populated by a simplecursoradapter. When I gather the information from the cursor is only gives me the value from the most recent item in the list.
Example:
lbs = (TextView)view.findViewById(R.id.GrainLbs);
lbs.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent arg1) {
if(!popState){
parentActivity.showPopup(v, mView, getId, String.valueOf(getLbs));
Log.i("Current ID", "");
}
setPopState();
return true;
}
});
I’m trying to pass the value from the database to a method in my activity from within my custom simplecursoradapter (String.valueOf(getLbs)) which since i’m gathering this information by clicking on an object in the listview I thought it would automatically use the data from the specific list item. Is there a way I can get the list item position and then use info from the database based on the position?
This turned out to be such a simple answer and I can’t believe i’ve spent so much time trying to figure it out. Because I was collecting the value within an inside method (an onclicklistener) I needed to make my variable final, it was declared at the beginning of the class so it could be used throughout, and because of this I wasn’t getting an exception, but I needed to make it final before it would pass the correct value for whatever reason.
So I guess if you bind your views within a customcursoradapter you can collect values for each individual listitem without knowing the position, it automatically knows this for you.