Reputation: 33
My English is not very good. Sorry. I am trying to learn to do Android application. But I have a problem. I'm adding Android SQlite content. And I'm getting them one by one. I do previous and next paging with buttons. Next = id+1
,Previous = id-1
So far everything is normal. But when I delete these contents id remains empty.
eg. id - name - age
1 - Name - 26
2 - Name - 32
3 - Name - 31
4 - Name - 21
when I delete the id content 2
id - name - age
1 - Name - 26
3 - Name - 31
4 - Name - 21
I can't getting content because id is empty when I press Next button. How can I solve this problem? Can I reset the id values after each deletion?
id - name - age
1 - Name - 26
2 - Name - 31
3 - Name - 21
Please help me.
Upvotes: 1
Views: 887
Reputation: 310
you need to get all row from table one in list and the on next and previous button iterate list like this. int currentIndex=0
nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(currentIndex<dataList.size()-1)
{
currentIndex++;
setCurrentItem(dataList.get(currentIndex));
}
}
});
previuosButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(currentIndex>0)
{
currentIndex--;
setCurrentItem(dataList.get(currentIndex))
}
}
});
Upvotes: 2