목록보기가있는 앱이 있습니다. listview 잘 작동합니다. 문제가 시작되면서 표시된 행의 일부부터 목록을 시작합니다. 내가 누를 때 행을 표시 할 수 있습니다. 그러나 초기화 할 때 행을 표시하는 방법을 찾지 않는 것 같습니다.ListView에서보기를 표시하는 방법은 무엇입니까?
가내가 그것을 어떻게
listViewOfBluetooth = getListView();
setInitialEnabledDevices();
listViewOfBluetooth.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String chosenBluetoothDevice = (String) ((TextView) view).getText();
BluetoothEnableOrDisable(view, chosenBluetoothDevice);
Toast.makeText(getApplicationContext(), chosenBluetoothDevice, Toast.LENGTH_SHORT).show();
editor.putString("bluetooth_name_from_list1", chosenBluetoothDevice);
editor.putBoolean("have_the_cars_bluetooth", true);
editor.commit();
Intent intent = new Intent(List.this, ParkOGuardActivity.class);
startActivity(intent);
}
});
}
public static void setInitialEnabledDevices(){
int length = listViewOfBluetooth.getChildCount();
View view = null;
String first = prefs.getString("bluetooth_name_from_list0", "");
String second = prefs.getString("bluetooth_name_from_list1", "");
String third = prefs.getString("bluetooth_name_from_list2", "");
for(int i = 0; i < length; i++){
view = listViewOfBluetooth.getChildAt(i);
if(view.equals(first) || view.equals(second) || view.equals(third)) {
view.setBackgroundColor(Color.GRAY);
}
}
}
을 를 해결할 수 :
이 내 코드?
감사합니다.
어떤 어댑터를 사용하고 있습니까? – Shaiful
나는 listadapter를 사용한다 : setListAdapter (new ArrayAdapter (this, R.layout.list, arrayOfBluetoothDevicesNames)); –
roiberg
ArrayAdapter를 확장하는 어댑터를 만드는 이유는 무엇입니까? 그리고 getView() 메소드를 대체하십시오. – IvoryCirrus