在我的应用程序中使用了简单的列表视图,用于显示数据库中的字符串内容。
如果我点击下一个项目,我有一个名为 next 的按钮,它会以某种颜色突出显示,它可以工作,但问题是如果项目超过 7 个项目,然后单击“下一步”按钮会强制关闭。有什么问题。请给我解决它的想法。
编辑:
我使用简单的列表视图在其上显示项目,这是因为列表视图到达列表视图的末尾(底部)还是其他问题?你能告诉我我遇到的这个问题有什么问题吗?
我的代码用于“下一步”按钮:
else if(v.getId()==R.id.buttonBookmarkrNext)
{
if((pos+1) == length)
{
//if no of files exist in a arraylist and current position of a file matches do the following
pos = 0;
audiofile=(String) lv.getItemAtPosition(pos);
Toast.makeText(this, " next file1",Toast.LENGTH_SHORT).show();
lv.getChildAt(length-1).setBackgroundColor(0x00000000);
lv.getChildAt(pos).setBackgroundColor(Color.LTGRAY);
}
else if(pos<length)
{
//if no of files exist in a arraylist(lenght) are greater than current position(pos) of a file do the following
pos ++;
//audioDetails = (ArrayList<String[]>) lv.getItemAtPosition(pos);
audiofile=(String) lv.getItemAtPosition(pos);
Toast.makeText(this, " next file",Toast.LENGTH_SHORT).show();
lv.getChildAt(pos-1).setBackgroundColor(0x00000000);
lv.getChildAt(pos).setBackgroundColor(Color.LTGRAY);
String str=(String) lv.getItemAtPosition(pos);
//Log.e("next file end",str);
Toast.makeText(this, " end file"+str,Toast.LENGTH_SHORT).show();
}
}