Java Code Examples for android.widget.ListView#invalidate()

The following examples show how to use android.widget.ListView#invalidate() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
 * Updates the existing dialog to show a list of available sensors
 * from the specified node. List items will be set when they are
 * available through an @AvailableSensorsUpdatedListener.
private void showSensorSelectionForNode(String nodeId) {
    String nodeName = app.getGoogleApiMessenger().getNodeName(nodeId);
    Log.d(TAG, "Showing sensor selection for node: " + nodeName + " - " + nodeId);

    // prepare dialog for new sensor selection
    String title = getString(R.string.loading_sensors_on_device).replace("[DEVICENAME]", nodeName);

    // update icon
    if (nodeId != null && nodeId.equals(app.getGoogleApiMessenger().getLocalNodeId())) {
    } else {

    // create & apply new list adapter
    multiChoiceAdapter = new SensorListAdapter(new ArrayList<DeviceSensor>(), getActivity());
    ListView listView = ((AlertDialog) getDialog()).getListView();

    // update layout params & invalidate list view
    ((ViewGroup.MarginLayoutParams) listView.getLayoutParams()).setMargins((int) UnitHelper.convertDpToPixel(16, getActivity()), 0, 0, 0);

    // update available sensors
    AvailableSensorsUpdatedListener availableSensorsUpdatedListener = createAvailableSensorsUpdatedListener();
    if (availableSensors.containsKey(nodeId)) {
        // set sensors
        availableSensorsUpdatedListener.onAvailableSensorsUpdated(nodeId, availableSensors.get(nodeId));
    } else {
        // request sensors
        requestAvailableSensors(nodeId, availableSensorsUpdatedListener);

    // track analytics event
    Bundle bundle = new Bundle();
    bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "Device Sensors");
    bundle.putString(FirebaseAnalytics.Param.VALUE, nodeName);
    app.getAnalytics().logEvent(FirebaseAnalytics.Event.VIEW_ITEM_LIST, bundle);