我正在使用getNeighboringCellInfo()
获取TelephonyManager
。我希望在列表视图中列出相邻广告的详细信息。我成功获取了相邻的广告但我无法显示在列表视图中请帮我解决这个问题。
listedSignals = (ListView)findViewById(R.id.listSignals);
private void getNeighbors(TelephonyManager telephonyManager) throws InterruptedException {
List<NeighboringCellInfo> neighboringCellInfos;
neighboringCellInfos = telephonyManager.getNeighboringCellInfo();
neighboringCellBlockingQueue = new LinkedBlockingQueue<>(100);
for (int i = 0;i < neighboringCellInfos.size();i++) {
NeighboringCellInfo info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS);
ArrayList<NeighboringCellInfo> cellInfoList = new ArrayList<>(neighboringCellBlockingQueue.size() + 1);
while (info != null) {
cellInfoList.add(info);
info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS);
}
neighboringCellInfos = cellInfoList;
}
}
neighboringCellInfos
包含所有相邻单元格的详细信息。所以请在neighboringCellInfos
列表视图中使用listedSignals
告诉我。
答案 0 :(得分:1)
您需要创建一个adapter
特定于您要在ListView
中显示的信息(此处已有many examples of this)。使用您自己的自定义适配器,您可以定义要在ListView
中显示的信息。完成后,您只需将列表添加到适配器,并在活动中设置adapter
的{{1}},如下所示:
ListView