-1

I am getting the getNeighboringCellInfo() using TelephonyManager .I want list out the neighboringcells details in the listview.I successfully getting the neighboringcells but I could't display in the list view Please help me solve this problem.

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;
   }
}

the neighboringCellInfos have the details of all neighboring cells.So please tell me using neighboringCellInfos in the listedSignalslistview.

reegan29
  • 920
  • 1
  • 12
  • 30
  • 1
    First of all you should move `ArrayList cellInfoList = new ArrayList<>(neighboringCellBlockingQueue.size() + 1);` out of the for loop because that gets created again everytime inside the for loop, resetting the previous added value to nothing again. – WonderWorld Mar 26 '15 at 14:07

1 Answers1

1

You need to create an adapter specific to the information you want to display in your ListView (there are many examples of this already here on SO). With your own custom adapter you're able to define what information you want displayed within your ListView. Once you've done that you simply add your list to your adapter and set the adapter of your ListView in your activity like so:

CustomListAdapter myAdapter = new CustomListAdapter(this, cellInfoList, ...);
listedSignals.setListAdapter(myAdapter);
Community
  • 1
  • 1
bwegs
  • 3,769
  • 2
  • 30
  • 33