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.
多くの変数(約1000)を含むリストビューがあります。特定の文字列変数 (「Washington」など) の位置を取得するにはどうすればよいですか? つまり、変数の名前 (都市の名前) を知って、リストビューでの位置を取得する方法を言いたいと思います。
使用しているものによって異なりListAdapterます。文字列の単純な配列がある場合ArrayAdapter、コードは次のようになります。
ListAdapter
ArrayAdapter
ArrayAdapter arrayAdapter = (ArrayAdapter) listView.getAdapter(); int position = arrayAdapter.getPosition("Washington");