私のアプリケーションでは、DB から文字列の内容を表示する単純なリストビューを使用していました。
次のアイテムをクリックすると次のボタンが呼び出され、色で強調表示されますが、問題はアイテムが7つ以上のアイテムであり、[次へ]ボタンをクリックするとforcecloseが発生することです。問題は何ですか.教えてくださいそれを解決するためのアイデア。
編集:
単純なリストビューを使用して項目を表示しましたが、これはリストビューがリストビューの終わり (下部) に達したためか、またはその他の問題が原因ですか?この問題に遭遇したことの何が問題なのか教えてもらえますか?
私のコードは「次へ」ボタン用です:
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();
}
}