//这不起作用 它显示第一个记录并在此之后停止.我想要一个即使在最后一条记录之后也能继续运行的循环.我明白了光标从位置0开始
.//代码
cur=db.getData(position);
switch(v.getId())
{
case R.id.next :
{
if (cur != null && cur.getCount()> 0 && position < cur.getCount() && position != cur.getCount()){
cur.moveToPosition(position);
textView1.setText(""+cur.getString(1));// Display Columns
position++;
cur.moveToNext();
}
}
Run Code Online (Sandbox Code Playgroud)
//我想要一个循环来显示记录号
下一个按钮,例如:
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
Run Code Online (Sandbox Code Playgroud)
后退按钮例如:
5 4 3 2 1 5 4 3 2 1
Run Code Online (Sandbox Code Playgroud)
随机按钮例如:
3 4 5 1
5 1 2 3
4 5 1 2
Run Code Online (Sandbox Code Playgroud)
出现该异常,因为您试图将对象放在不存在的位置.记住索引从0开始.
直接来自DOCS:
public abstract boolean moveToPosition (int position)
Run Code Online (Sandbox Code Playgroud)
在API级别1中添加
将光标移动到绝对位置.有效值范围为-1 <= position <= count.
如果请求目标是可访问的,则此方法将返回true,否则返回false.参数定位要移动到的从零开始的位置.返回
whether the requested move fully succeeded.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2448 次 |
| 最近记录: |