List of usage examples for android.widget ArrayAdapter notifyDataSetChanged
@Override public void notifyDataSetChanged()
From source file:Main.java
public static void fillLeftList(String[] pairsList, List<String> namesList, ArrayAdapter<String> adapter) { String[] names;//from ww w . ja v a 2s .c om if (pairsList.length != 0) { namesList.clear(); for (String s : pairsList) { names = s.split("-"); if (!namesList.contains(names[0])) { namesList.add(names[0]); } } if (adapter != null) { adapter.notifyDataSetChanged(); } } }
From source file:Main.java
public static void fillRightList(String[] pairsList, List<String> namesList, ArrayAdapter<String> adapter, String targetPair) {//w w w.j a v a2s.c o m String[] componentsList; String targetName = targetPair.split("-")[0]; if (targetPair.length() != 0) { namesList.clear(); for (String s : pairsList) { componentsList = s.split("-"); if (componentsList[0].equals(targetName)) { namesList.add(componentsList[1]); } } if (adapter != null) { adapter.notifyDataSetChanged(); } } }
From source file:com.sun.utils.StatusFragment.java
private void notifyAdapters() { for (ArrayAdapter<String> adapter : adapters) { adapter.notifyDataSetChanged(); } }
From source file:com.scoreminion.GameSourcesApiFetcherAsyncTask.java
/** * Updates the underlying list and notifies the adaptor that the contents have changed. * * @param result the result of the API call to retrieve the games *//*from w w w .j av a 2 s . com*/ @Override protected void onPostExecute(List<ScoresMessagesGameSource> result) { Log.d(TAG, "post execute: " + result); if (fragment.getGameSources() == null) { Log.d(TAG, "Game sources is null"); return; } fragment.getGameSources().clear(); fragment.getGameSources().addAll(result); if (fragment.getListAdapter() == null) { Log.d(TAG, "List adapter is null"); return; } ArrayAdapter arrayAdapter = (ArrayAdapter) fragment.getListAdapter(); if (arrayAdapter != null) { arrayAdapter.notifyDataSetChanged(); } }
From source file:com.google.plus.wigwamnow.PlusSettingsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mMenuOptions = getResources().getStringArray(R.array.plus_settings); // Display each element of OPTIONS as a list item ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, mMenuOptions);/*from ww w . j ava2 s.com*/ setListAdapter(adapter); adapter.notifyDataSetChanged(); }
From source file:com.sample.starternativeandroid.MyInvokeListener.java
public void onSuccess(WLResponse response) { try {/*from w w w . j av a 2s. c o m*/ JSONArray items = (JSONArray) response.getResponseJSON().get("items"); Log.d("InvokeSuccess", items.toString()); if (items != null && items.length() > 0) { Content.ITEMS.clear(); for (int i = 0; i < items.length(); i++) { Content.addItem(new Content.Item(items.getJSONObject(i))); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } final ArrayAdapter<Content.Item> adapter = this.adapter; this.activity.runOnUiThread(new Runnable() { @Override public void run() { adapter.notifyDataSetChanged(); } }); }
From source file:org.kaaproject.kaa.demo.notification.activity.MainActivity.java
private void updateAdapter(final ArrayAdapter adapter) { runOnUiThread(new Runnable() { @Override// w w w .j a v a 2 s . c o m public void run() { adapter.notifyDataSetChanged(); } }); }
From source file:com.example.meind.meinders_habittracker.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/* w ww . ja v a 2 s . c o m*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_home) { // Handle the camera action } else if (id == R.id.nav_history) { Intent intent2 = new Intent(this, History_page.class); startActivity(intent2); } else if (id == R.id.nav_reset) { //got from //http://www.tutorialspoint.com/android/android_alert_dialoges.htm AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage("Are you sure you want to delete all data?"); alertDialogBuilder.setPositiveButton("yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { HabitListController.getHabitList().removeHabits(); HabitListController.getHabitList().notifyListener(); HabitListController.getHabitList().addListener(new Listener() { @Override public void update() { //updating the list once it gets deleted ListView listview = (ListView) findViewById(R.id.HabitList); final ArrayList<Habit> habitsArrayList = HabitListController.getHabitList() .getAllHabits(); final ArrayAdapter<Habit> HabitAdapter = new ArrayAdapter<Habit>(MainActivity.this, android.R.layout.simple_list_item_1, habitsArrayList); listview.setAdapter(HabitAdapter); HabitAdapter.notifyDataSetChanged(); } }); Toast.makeText(MainActivity.this, "All data has been deleted!", Toast.LENGTH_LONG).show(); } }); alertDialogBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //do nothing } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:de.domjos.schooltools.activities.LearningCardOverviewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.learning_card_overview_activity); this.initControls(); this.cmdLearningCardQueryStart.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . java2 s.c o m*/ public void onClick(View v) { final LearningCardQueryTraining learningCardQueryTraining = new LearningCardQueryTraining(); if (cmdLearningCardQueryStart.getText().equals(getString(R.string.learningCard_query))) { final Dialog dialog = new Dialog(LearningCardOverviewActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.learning_card_dialog); dialog.setCancelable(true); final Spinner spLearningCardQuery = dialog.findViewById(R.id.spLearningCardQueries); final ArrayAdapter<LearningCardQuery> learningCardQueries = new ArrayAdapter<>( getApplicationContext(), android.R.layout.simple_spinner_item, MainActivity.globals.getSqLite().getLearningCardQueries("")); spLearningCardQuery.setAdapter(learningCardQueries); learningCardQueries.notifyDataSetChanged(); final Button btnStartSop = dialog.findViewById(R.id.cmdStart); btnStartSop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { learningCardQueryTraining.setLearningCardQuery( learningCardQueries.getItem(spLearningCardQuery.getSelectedItemPosition())); learningCardQueryTraining.setID(MainActivity.globals.getSqLite() .insertOrUpdateLearningCardQueryTraining(learningCardQueryTraining)); cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query_end)); fragmentAdapter.setQuery(learningCardQueryTraining); viewPager.setAdapter(fragmentAdapter); dialog.dismiss(); } }); dialog.show(); } else { int wrongCards = 0, rightCards = 0, firstTry = 0, secondTry = 0, thirdTry = 0; LearningCardQueryTraining reloadedTraining = MainActivity.globals.getSqLite() .getLearningCardQueryTraining("ID=" + learningCardQueryTraining.getID()).get(0); for (LearningCardQueryResult result : reloadedTraining.getResults()) { if (result.isResult1() || result.isResult2() || result.isResult3()) { rightCards++; if (result.isResult1()) { firstTry++; } else if (result.isResult2()) { secondTry++; } else { thirdTry++; } } else { wrongCards++; } } AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( LearningCardOverviewActivity.this); alertDialogBuilder.setTitle(R.string.learningCard_result); String content = String.format("%s %s%n%s %s%n%s %s%n%s %s%n%s %s%n", getString(R.string.learningCard_result_right), rightCards, getString(R.string.learningCard_result_wrong), wrongCards, getString(R.string.learningCard_result_firstTry), firstTry, getString(R.string.learningCard_result_secondTry), secondTry, getString(R.string.learningCard_result_thirdTry), thirdTry); alertDialogBuilder.setMessage(content); alertDialogBuilder.create().show(); cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query)); fragmentAdapter.setQuery(null); viewPager.setAdapter(fragmentAdapter); } } }); }
From source file:com.sandklef.coachapp.fragments.MemberFragment.java
public void updateMemberList() { Log.d(LOG_TAG, " updateMemberList() for team: " + LocalStorage.getInstance().getCurrentTeam()); try {/* ww w.j a va2s.c om*/ ArrayAdapter<Member> ma = ((ArrayAdapter) mAdapter); ma.clear(); List<Member> members = MemberFilterEngine.apply(Storage.getInstance().getMembers(), MemberTeamFilter.newMemberTeamFilter(LocalStorage.getInstance().getCurrentTeam())); ma.addAll(members); ma.notifyDataSetChanged(); } catch (StorageNoClubException e) { e.printStackTrace(); } }