Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文字列配列が入力されたListViewがあります。アイテムを動的に選択したいのですが、.setSelection(1)と.setSelectionFromTop(1,100)が機能しません。
list.setSelection(2); Log.i(TAG, "my pos: "+ list.getSelectedItemPosition());
これは「mypos:-1」をトレースします
誰かアイデアはありますか?
setSelection()そしてgetSelectedItemPosition()2つの異なることを参照してください。
setSelection()
getSelectedItemPosition()
「選択」は、のように最初に表示される行を指しgetFirstVisiblePosition()ます。 「選択済み」とは、のように選択されたビューを指しますView#setSelected()。
getFirstVisiblePosition()
View#setSelected()
あなたはどれが欲しいですか?