Example usage for android.widget ArrayAdapter notifyDataSetChanged

List of usage examples for android.widget ArrayAdapter notifyDataSetChanged

Introduction

In this page you can find the example usage for android.widget ArrayAdapter notifyDataSetChanged.

Prototype

@Override
    public void notifyDataSetChanged() 

Source Link

Usage

From source file:com.tsroad.map.poisearch.PoiKeywordSearchActivity.java

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
    String newText = s.toString().trim();
    Inputtips inputTips = new Inputtips(PoiKeywordSearchActivity.this, new InputtipsListener() {

        @Override/*  w w w.  j  a  v a2s .  com*/
        public void onGetInputtips(List<Tip> tipList, int rCode) {
            if (rCode == 0) {// 
                List<String> listString = new ArrayList<String>();
                for (int i = 0; i < tipList.size(); i++) {
                    listString.add(tipList.get(i).getName());
                }
                ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(getApplicationContext(),
                        R.layout.route_inputs, listString);
                searchText.setAdapter(aAdapter);
                aAdapter.notifyDataSetChanged();
            }
        }
    });
    try {
        inputTips.requestInputtips(newText, editCity.getText().toString());// ??????

    } catch (AMapException e) {
        e.printStackTrace();
    }
}

From source file:com.mifos.mifosxdroid.online.GenerateCollectionSheetFragment.java

public void inflateGroupSpinner(final int centerId) {

    API.centerService.getAllGroupsForCenter(centerId, new Callback<CenterWithAssociations>() {
        @Override/*from w  w w .  ja v  a2s.  c om*/
        public void success(CenterWithAssociations centerWithAssociations, Response response) {

            List<Group> groups = centerWithAssociations.getGroupMembers();

            List<String> groupNames = new ArrayList<String>();

            groupNames.add(getString(R.string.spinner_group));
            groupNameIdHashMap.put(getString(R.string.spinner_group), -1);

            for (Group group : groups) {
                groupNames.add(group.getName());
                groupNameIdHashMap.put(group.getName(), group.getId());
            }

            ArrayAdapter<String> groupAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, groupNames);

            groupAdapter.notifyDataSetChanged();

            groupAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            sp_groups.setAdapter(groupAdapter);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

        }
    });

}

From source file:com.mifos.mifosxdroid.online.GenerateCollectionSheetFragment.java

public void inflateGroupSpinner(final int officeId, int staffId) {

    Map<String, Object> params = new HashMap<String, Object>();

    params.put(LIMIT, -1);/*from w w  w.  j  a  va  2s . com*/
    params.put(ORDER_BY, ORDER_BY_FIELD_NAME);
    params.put(SORT_ORDER, ASCENDING);
    if (staffId >= 0) {
        params.put(STAFF_ID, staffId);
    }

    API.groupService.getAllGroupsInOffice(officeId, params, new Callback<List<Group>>() {
        @Override
        public void success(List<Group> groups, Response response) {

            List<String> groupNames = new ArrayList<String>();

            groupNames.add(getString(R.string.spinner_group));
            groupNameIdHashMap.put(getString(R.string.spinner_group), -1);

            for (Group group : groups) {
                groupNames.add(group.getName());
                groupNameIdHashMap.put(group.getName(), group.getId());
            }

            ArrayAdapter<String> groupAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, groupNames);

            groupAdapter.notifyDataSetChanged();

            groupAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            sp_groups.setAdapter(groupAdapter);

        }

        @Override
        public void failure(RetrofitError retrofitError) {

        }
    });

}

From source file:ca.ualberta.cs.shoven_habittracker.AllHabitsActivity.java

@Override
protected void onResume() {
    super.onResume();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    setNavigator(navigationView);//from   www  . j  a  v a 2  s  .  c  o m

    ListView listView = (ListView) findViewById(R.id.allHabitsListView);
    final ArrayList<Habit> habitList = controller.getAllHabits().getHabitList();
    final ArrayAdapter<Habit> habitAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
            habitList);
    listView.setAdapter(habitAdapter);
    listView.setOnItemClickListener(AllHabitsActivity.this);

    WeeklyScheduleController.getWeeklySchedule().addListener(new Listener() {
        @Override
        public void update() {
            habitAdapter.notifyDataSetChanged();
        }
    });
}

From source file:it.baywaylabs.jumpersumo.MainActivity.java

@Override
public void onServicesDevicesListUpdated() {
    Log.d(TAG, "onServicesDevicesListUpdated ...");

    List<ARDiscoveryDeviceService> list;

    if (ardiscoveryService != null) {
        list = ardiscoveryService.getDeviceServicesArray();

        deviceList = new ArrayList<ARDiscoveryDeviceService>();
        List<String> deviceNames = new ArrayList<String>();

        if (list != null) {
            for (ARDiscoveryDeviceService service : list) {
                Log.d(TAG, "service :  " + service + " name = " + service.getName());
                ARDISCOVERY_PRODUCT_ENUM product = ARDiscoveryService
                        .getProductFromProductID(service.getProductID());
                Log.d(TAG, "product :  " + product);
                // only display Jumping Sumo EVO RACE
                if (ARDISCOVERY_PRODUCT_ENUM.ARDISCOVERY_PRODUCT_JS_EVO_RACE.equals(product)) {
                    deviceList.add(service);
                    deviceNames.add(service.getName());
                }//from  ww w.  java 2 s .c  o  m
            }
        }

        deviceNameList = deviceNames.toArray(new String[deviceNames.size()]);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.row, R.id.textViewList,
                deviceNameList);
        adapter.notifyDataSetChanged();

        // Assign adapter to ListView
        listView.setAdapter(adapter);

        Log.d(TAG, "DEVICES: " + deviceNameList.length);
    }

}

From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java

@Override
public void onGetInputtips(List<Tip> tipList, int rCode) {
    if (rCode == 1000) {
        List<String> listString = new ArrayList<String>();
        for (int i = 0; i < tipList.size(); i++) {
            listString.add(tipList.get(i).getName());
        }//w ww  .  jav  a  2s  .c  om
        ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(this, R.layout.route_inputs, listString);
        mResultText.setAdapter(aAdapter);
        aAdapter.notifyDataSetChanged();
    } else {
        showToast(rCode + "");
    }
}

From source file:com.mifos.mifosxdroid.online.GenerateCollectionSheetFragment.java

public void inflateStaffSpinner(final int officeId) {

    API.staffService.getStaffForOffice(officeId, new Callback<List<Staff>>() {
        @Override/*  ww w .  jav a 2 s .  c o  m*/
        public void success(List<Staff> staffs, Response response) {

            final List<String> staffNames = new ArrayList<String>();

            staffNames.add(getString(R.string.spinner_staff));
            staffNameIdHashMap.put(getString(R.string.spinner_staff), -1);

            for (Staff staff : staffs) {
                staffNames.add(staff.getDisplayName());
                staffNameIdHashMap.put(staff.getDisplayName(), staff.getId());
            }

            ArrayAdapter<String> staffAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, staffNames);

            staffAdapter.notifyDataSetChanged();

            staffAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            sp_loan_officers.setAdapter(staffAdapter);

            sp_loan_officers.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                    int staffId = staffNameIdHashMap.get(staffNames.get(position));

                    if (staffId != -1) {

                        inflateCenterSpinner(officeId, staffId);
                        inflateGroupSpinner(officeId, staffId);

                    } else {

                        Toast.makeText(getActivity(), getString(R.string.error_select_staff),
                                Toast.LENGTH_SHORT).show();

                    }

                }

                @Override
                public void onNothingSelected(AdapterView<?> parent) {

                }
            });

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            System.out.println(retrofitError.getLocalizedMessage());

        }
    });

}

From source file:com.mifos.mifosxdroid.online.GenerateCollectionSheetFragment.java

public void inflateOfficeSpinner() {

    safeUIBlockingUtility.safelyBlockUI();

    API.officeService.getAllOffices(new Callback<List<Office>>() {
        @Override//from  w w  w .ja  v  a 2s.c  om
        public void success(List<Office> offices, Response response) {

            final List<String> officeNames = new ArrayList<String>();
            officeNames.add(getString(R.string.spinner_office));
            officeNameIdHashMap.put(getString(R.string.spinner_office), -1);
            for (Office office : offices) {
                officeNames.add(office.getName());
                officeNameIdHashMap.put(office.getName(), office.getId());
            }

            ArrayAdapter<String> officeAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, officeNames);

            officeAdapter.notifyDataSetChanged();

            officeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            sp_offices.setAdapter(officeAdapter);

            sp_offices.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                    int officeId = officeNameIdHashMap.get(officeNames.get(position));

                    if (officeId != -1) {

                        inflateStaffSpinner(officeId);
                        inflateCenterSpinner(officeId, -1);
                        inflateGroupSpinner(officeId, -1);

                    } else {

                        Toast.makeText(getActivity(), getString(R.string.error_select_office),
                                Toast.LENGTH_SHORT).show();

                    }

                }

                @Override
                public void onNothingSelected(AdapterView<?> parent) {

                }
            });

            safeUIBlockingUtility.safelyUnBlockUI();

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            System.out.println(retrofitError.getLocalizedMessage());

            safeUIBlockingUtility.safelyUnBlockUI();
        }
    });

}

From source file:com.mifos.mifosxdroid.online.GenerateCollectionSheetFragment.java

public void inflateCenterSpinner(final int officeId, int staffId) {

    Map<String, Object> params = new HashMap<String, Object>();

    params.put(LIMIT, -1);/*from ww w . j a  v  a 2 s .com*/
    params.put(ORDER_BY, ORDER_BY_FIELD_NAME);
    params.put(SORT_ORDER, ASCENDING);
    if (staffId >= 0) {
        params.put(STAFF_ID, staffId);
    }

    API.centerService.getAllCentersInOffice(officeId, params, new Callback<List<Center>>() {
        @Override
        public void success(List<Center> centers, Response response) {

            final List<String> centerNames = new ArrayList<String>();

            centerNames.add(getString(R.string.spinner_center));
            centerNameIdHashMap.put(getString(R.string.spinner_center), -1);

            for (Center center : centers) {
                centerNames.add(center.getName());
                centerNameIdHashMap.put(center.getName(), center.getId());
            }

            ArrayAdapter<String> centerAdapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_spinner_item, centerNames);

            centerAdapter.notifyDataSetChanged();

            centerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            sp_centers.setAdapter(centerAdapter);

            sp_centers.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                    int centerId = centerNameIdHashMap.get(centerNames.get(position));

                    if (centerId != -1) {

                        inflateGroupSpinner(centerId);

                    } else {

                        Toast.makeText(getActivity(), getString(R.string.error_select_center),
                                Toast.LENGTH_SHORT).show();

                    }

                }

                @Override
                public void onNothingSelected(AdapterView<?> parent) {

                }
            });

        }

        @Override
        public void failure(RetrofitError retrofitError) {

            System.out.println(retrofitError.getLocalizedMessage());

        }
    });

}

From source file:it.baywaylabs.jumpersumo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    // Testing// w  w  w .j av a 2s .c  o m
    // String bella = "Hello, it's me. Can you turn left and go on and turn right and go left ancora and take photo va?";
    String bella = "hello can go on and execute http://www.baywaylabs.it/tesi/commands.txt";
    Finder f = new Finder();
    PriorityQueue pq = f.processingMessage(bella);
    /*
    while(!pq.isEmpty())
    {
    Log.e(TAG, ((Command)pq.peek()).getCmd() );
    pq.remove();
    }
    */
    List<String> prova = f.getStringQueue(pq);
    for (String s : prova) {
        Log.e(TAG, "Stringa: " + s);
    }
    File folder = new File(Constants.DIR_ROBOT);
    FileFilter ff = new FileFilter();
    File[] list = folder.listFiles(ff);
    Log.e(TAG, "Lista file: " + list.length);
    for (int p = 0; p < list.length; p++)
        Log.e(TAG, "Nome file: " + list[p].getName());
    String urlReal = f.getUrls(bella).get(0);
    Log.e(TAG, "Url Stringa numero 1: " + urlReal);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.HelloOpenCvView);
    // mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
    mOpenCvCameraView.setCvCameraViewListener(MainActivity.this);
    // End Testing

    SharedPreferences sharedPref = MainActivity.this.getSharedPreferences(Constants.MY_PREFERENCES,
            Context.MODE_PRIVATE);
    Log.d(TAG, "Vediamo se ho memorizzato bene: " + sharedPref.getLong(Constants.LAST_ID_MENTIONED, 0));

    initBroadcastReceiver();
    initServiceConnection();

    listView = (ListView) findViewById(R.id.list);

    deviceList = new ArrayList<ARDiscoveryDeviceService>();
    deviceNameList = new String[] {};
    Log.d(TAG, "DEVICES: " + deviceList.toString());

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.row, R.id.textViewList,
            deviceNameList);
    adapter.notifyDataSetChanged();

    // Assign adapter to ListView
    listView.setAdapter(adapter);

    //ListView Item Click Listener
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            ARDiscoveryDeviceService service = deviceList.get(position);

            Intent intent = new Intent(MainActivity.this, PilotingActivity.class);
            intent.putExtra(PilotingActivity.EXTRA_DEVICE_SERVICE, service);

            startActivity(intent);
        }

    });
}