我知道如何獲得Android Wifi掃描,但我無法弄清楚製作列表適配器的最佳方式。我想只將SSID和BSSID從一次掃描綁定到text1和text2。什麼我一直在做如何將Android Wifi掃描結果放入列表中?
wifi.startScan();
// get list of the results in object format (like an array)
List<ScanResult> results = wifi.getScanResults();`
// loop that goes through list
for (ScanResult result : results) {
Toast.makeText(this, result.SSID + " " + result.level,
Toast.LENGTH_SHORT).show();
而且
樣品:
private void fillDataFromDb() {
Cursor scanCursor = Db.fetchAllScans();
startManagingCursor(scanCursor);`
// Create an array to specify the fields we want to display in the list
// (only TITLE)
String[] from = new String[] { WifiDbAdapter.KEY_BSSID,
WifiDbAdapter.KEY_SSID };
// and an array of the fields we want to bind those fields to (in this
// case just text1)
int[] to = new int[] { R.id.text1, R.id.text2 };
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter scansdb = new SimpleCursorAdapter(this,
R.layout.scan_row, scanCursor, from, to);
setListAdapter(scansdb);
}
我想看到一些代碼,你有太多。你是否得到這樣的結果?:列表 results = wifi.getScanResults(); –
eternalmatt
2011-03-27 22:40:14
我已經這樣做了,只是得到吐司消息: 'wifi.startScan(); \t \t //以對象格式獲得結果列表(如數組) \t \t列表 results = wifi.getScanResults(); \t \t //循環通過列表 \t \t無二(ScanResult結果:結果){ \t \t \t Toast.makeText(這一點,result.SSID + 「」 + result.level, \t \t \t \t \t吐司.LongTH_SHORT).show();' –
2011-03-27 23:08:52
@eternalmatt是的,這正是我如何得到的結果,它的工作原理,只是不知道如何綁定到列表視圖 – 2011-03-27 23:14:26