I’m having a very simple problem, which can be solved fairly simple but for some reason I cannot figure it out why is it not working.
I have a view composed of 6 Listviews and when the user clicks on a detail position I’m returning the position.
This position will be used to get the items from an entire row in a database.
When passing the position to another activity, The detail activity, the position I get is the one which I initialized, which is 0.
Here is my code.
1st Activity
The item click listener:
detailsLi.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> aV, View v, int arg2,
long arg3) {
// TODO Auto-generated method stub
/*
* Intent openDetails = new Intent(
* "com.DCWebMakers.Vairon.APPOINTMENTDETAILS");
* startActivity(openDetails);
*/
positionView = detailsLi.getSelectedItemPosition();
Dialog showPosition = new Dialog(MyAppointment.this);
showPosition.setTitle("Position is:" + positionView);
}
});
the return position method:
public Integer getPosition() {
return positionView;
}
2nd activity
Setting the row:
AppointmentInfo details = new AppointmentInfo(this);
details.open();
String name = details.getName(new MyAppointment().getPosition());
details.close();
So, is the return position method not being used correctly?
Thanks.
A new instance will return your default value. You should be passing the position:
In your list item click: