1

ListView各行には と が含まれていSeekBarますTextView。のいずれかを移動するときはいつでも、更新されたライブにSeekBarすべての を含める必要があります。TextViewListViewSeekBar

私はしようとしました

  • を呼び出しますnotifyDataSetChanged()ListViewSeekBarはフォーカスを失います。

  • ListView次のコードで をループします。

for (int i = 0; i < listView.getChildCount(); i++)
{
TextView tv = (TextView) listView.getChildAt(i).findViewById(R.id.textView1);
String value = getData();
tv.setText(value);
}

ただし、上記のコードは に永続的な更新を提供しませんListView。これは、ユーザーがスクロールした場合に問題になります。

この問題に対処する方法について何か提案はありますか?

4

1 に答える 1

1

SeekBar のいずれかを移動するたびに、SeekBar へのフォーカスを失うことなく、ListView 内のすべての TextView をライブで更新する必要があります。

あなたがしたいことは、アダプタのデータリストを呼び出さずにnotifyDataSetChanged()更新TextViewsし、現在表示されている行から更新することです。

//...
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    // found is a reference to the ListView    
    int firstVisible = found.getFirstVisiblePosition();
    // first update the mData which backs the adapter               
    for (int i = 0; i < mData.size(); i++) {
          // update update update   
    }
    // update the visible rows
    for (int j = 0; j < found.getChildCount(); j++) {
           final View row = found.getChildAt(j);
           // get the position from the mData by offseting j with the firstVisible position
       ((TextView) row.findViewById(R.id.theIdOfTheTextView)).setText(mData.get(firstVisible + j));
    }
}
//...

これにより、スムーズな更新が提供されるはずです。

于 2013-01-27T08:23:18.073 に答える