You have to un-highlight all that do not match cursor.getPosition()==longrowclick1
=]
is that not what the else part of the if condition does?
*** EDIT 1 ***
Ok the IF else I was using was within that IF of the cursor.getPosition()==longrowclick1
I have now had to create the myviewp View object as a global object as it does not see the defined version within the IF of the cursor.getPosition()==longrowclick1 . However the "other" row is still getting highlighted but now instead of it highlighting the whole row as it was doing before it is highlighting the individual view objects such as the textview and imageview etc.
I think I might know what is causing this but it is how to resolve it. I have (as you may have seen one of my previous posts in this thread) a separator which creates a visual coloured line whenever there is a new day of the month. This has to move back a record to determine if that record is on the same day etc that the current. I think this has something to do with it but I am trying to understand on why it moves to the 6th (really the 7th but as you know the index starts at 0) row when I long click on the 1st row which is position 0.
*** EDIT 2 ***
Cracked it now, it was related to the date separator section but it appears that the below code (which I have commented ) now works and another problem I had (which is now fixed) was when highlighted a row where the separator was above, this then blanked the separator out , now solved :
[HIGH]
// is the current cursor position the same that has been Long Clicked
if (cursor.getPosition()==longrowclick1) {
// sets up parent view of object
myviewp = (View) view.getParent();
// checks if parent view is valid (there are a lot here)
if (((View)view.getParent()).getId()==R.id.Table1 || ((View)view.getParent()).getId()==R.id.tableRow1 || ((View)view.getParent()).getId()==R.id.tableRow2 || ((View)view.getParent()).getId()==R.id.tableRow3 || ((View)view.getParent()).getId()==R.id.Table2 || ((View)view.getParent()).getId()==R.id.Table3 ) {
// If the parent views are valid set the background to dark slate blue
myviewp.setBackgroundResource(R.drawable.darkslateblue);
// if one of the child views are not the date separator then ..
if (view.getId()!=R.id.seper) {
// ... set them to the dark slate blue ...
view.setBackgroundResource(R.drawable.darkslateblue);
} else { // else if the child object is the date separator ..
// .. keep it as dark gray
view.setBackgroundColor(Color.DKGRAY);
}
return true;
}
} else {// if the cursor position does not match the Long Click Position then ..
// .. get the parent of the current child object ...
myviewp = (View) view.getParent();
// .. set the background of the parent to black ..
myviewp.setBackgroundColor(Color.BLACK);
// .. check to make sure that the child object is not the date separator ...
if (view.getId()!=R.id.seper) {
// .. and then set the child object background to black ..
view.setBackgroundColor(Color.BLACK);
} else { // .. else if it the child object is the date separator then ..
// .. set it to the dark gray background .
view.setBackgroundColor(Color.DKGRAY);
}
}
[/HIGH]
So thanks again to alostpack for your help on this matter. I would like to point out that when asking on another forum I got no reply whatsoever .
** EDIT 3 **
There is a new problem now since trying this again, it appears that any record above or below the date separator , when highlighted ends up changing to the record below it . As I am calling the notifydatachangedset which calls the viewbinder method, the separator logic is then called again and this someone causes the record to change its "Identity"
*** EDIT 4 ***
Sorted the above problem by removing the return true within this IF condition.
Thanks
TimCS