Example usage for android.widget ArrayAdapter clear

List of usage examples for android.widget ArrayAdapter clear

Introduction

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

Prototype

public void clear() 

Source Link

Document

Remove all elements from the list.

Usage

From source file:com.appdynamics.demo.gasp.fragment.TwitterResponderFragment.java

private void setTweets() {
    TwitterStreamActivity activity = (TwitterStreamActivity) getActivity();

    try {//from   w w w  .  ja  v  a 2  s . c  o  m
        // Get Twitter search keyword from Shared Preferences
        SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
        String keyword = gaspSharedPreferences.getString(getString(R.string.gasp_twitter_preferences), "");

        if (mTweets == null) {
            Intent intent = new Intent(activity, RESTIntentService.class);
            intent.setData(Uri.parse(TwitterAPI.getTwitterApiSearch()));

            Bundle params = new Bundle();
            params.putString("q", keyword);
            params.putString("count", "10");

            Bundle headers = new Bundle();
            headers.putString("Authorization", "Bearer " + TwitterStreamActivity.getTwitterOAuthToken());

            intent.putExtra(RESTIntentService.EXTRA_PARAMS, params);
            intent.putExtra(RESTIntentService.EXTRA_HEADERS, headers);
            intent.putExtra(RESTIntentService.EXTRA_RESULT_RECEIVER, getResultReceiver());

            activity.startService(intent);
        } else if (activity != null) {
            ArrayAdapter<String> adapter = activity.getArrayAdapter();

            adapter.clear();
            for (String tweet : mTweets) {
                adapter.add(tweet);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.cloudbees.gasp.fragment.TwitterResponderFragment.java

private void setTweets() {
    TwitterStreamActivity activity = (TwitterStreamActivity) getActivity();

    try {// ww  w  .j a v  a2  s.c om
        // Get Twitter search keyword from Shared Preferences
        SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
        String keyword = gaspSharedPreferences.getString(getString(R.string.gasp_twitter_preferences), "");

        if (mTweets == null && activity != null) {
            Intent intent = new Intent(activity, RESTIntentService.class);
            intent.setData(Uri.parse(TwitterAPI.getTwitterApiSearch()));

            Bundle params = new Bundle();
            params.putString("q", keyword);
            params.putString("count", "10");

            Bundle headers = new Bundle();
            headers.putString("Authorization", "Bearer " + TwitterStreamActivity.getTwitterOAuthToken());

            intent.putExtra(RESTIntentService.EXTRA_PARAMS, params);
            intent.putExtra(RESTIntentService.EXTRA_HEADERS, headers);
            intent.putExtra(RESTIntentService.EXTRA_RESULT_RECEIVER, getResultReceiver());

            activity.startService(intent);
        } else if (activity != null) {
            ArrayAdapter<String> adapter = activity.getArrayAdapter();

            adapter.clear();
            for (String tweet : mTweets) {
                adapter.add(tweet);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.cloudbees.gasp.fragment.TwitterSearchResponderFragment.java

private void setTweets() {
    TwitterRESTServiceActivity activity = (TwitterRESTServiceActivity) getActivity();

    if (mTweets == null && activity != null) {
        // This is where we make our REST call to the service. We also pass in our ResultReceiver
        // defined in the RESTResponderFragment super class.

        // We will explicitly call our Service since we probably want to keep it as a private
        // component in our app. You could do this with Intent actions as well, but you have
        // to make sure you define your intent filters correctly in your manifest.
        Intent intent = new Intent(activity, RESTService.class);
        intent.setData(Uri.parse("http://search.twitter.com/search.json"));

        // Here we are going to place our REST call parameters. Note that
        // we could have just used Uri.Builder and appendQueryParameter()
        // here, but I wanted to illustrate how to use the Bundle params.
        Bundle params = new Bundle();
        params.putString("q", "cloudbees");

        intent.putExtra(RESTService.EXTRA_PARAMS, params);
        intent.putExtra(RESTService.EXTRA_RESULT_RECEIVER, getResultReceiver());

        // Here we send our Intent to our RESTService.
        activity.startService(intent);/*  w w w.j  a va2s .c o  m*/
    } else if (activity != null) {
        // Here we check to see if our activity is null or not.
        // We only want to update our views if our activity exists.

        ArrayAdapter<String> adapter = activity.getArrayAdapter();

        // Load our list adapter with our Tweets.
        adapter.clear();
        for (String tweet : mTweets) {
            adapter.add(tweet);
        }
    }
}

From source file:org.delta.pass.SwipeRefreshChatList.java

/**
 * When the AsyncTask finishes, it calls onRefreshComplete(), which updates the data in the
 * ListAdapter and turns off the progress bar.
 *///ww w . j a  v a2 s .c o m
private void onRefreshComplete(List<String> result) {
    //Log.i(LOG_TAG, "onRefreshComplete");

    // Remove all items from the ListAdapter, and then replace them with the new items
    ArrayAdapter<String> adapter = (ArrayAdapter<String>) getListAdapter();
    adapter.clear();
    for (String cheese : result) {
        adapter.add(cheese);
    }

    // Stop the refreshing indicator
    setRefreshing(false);
}

From source file:com.sandklef.coachapp.fragments.MemberFragment.java

public void updateMemberList() {
    Log.d(LOG_TAG, " updateMemberList() for team: " + LocalStorage.getInstance().getCurrentTeam());
    try {//w ww  . j  ava  2s .co m
        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();
    }
}

From source file:com.app4am.app4am.LatestNewsListFragment.java

/**
 * When the AsyncTask finishes, it calls onRefreshComplete(), which updates the data in the
 * ListAdapter and turns off the progress bar.
 *//*from  w  ww. j ava 2s.  co  m*/
private void onRefreshComplete(List<String> result) {
    Log.i(LOG_TAG, "onRefreshComplete");

    // Remove all items from the ListAdapter, and then replace them with the new items
    try {
        ArrayAdapter<String> adapter = (ArrayAdapter<String>) getListAdapter();
        adapter.clear();
        for (String cheese : result) {
            adapter.add(cheese);
        }
    } catch (ClassCastException e) {
        Log.e(LOG_TAG, e.toString());
    }

    // Stop the refreshing indicator
    setRefreshing(false);
}

From source file:com.example.android.swiperefreshlistfragment.SwipeRefreshListFragmentFragment.java

/**
 * When the AsyncTask finishes, it calls onRefreshComplete(), which updates the data in the
 * ListAdapter and turns off the progress bar.
 *//*from w ww .  j a v  a2  s  . c o  m*/
private void onRefreshComplete(List<String> result) {
    Log.i(LOG_TAG, "onRefreshComplete");

    // Remove all items from the ListAdapter, and then replace them with the new items
    ArrayAdapter<String> adapter = (ArrayAdapter<String>) getListAdapter();
    adapter.clear();
    for (String cheese : result) {
        adapter.add(cheese);
    }

    // Stop the refreshing indicator
    setRefreshing(false);
}

From source file:com.microsoft.windowsazure.messaging.e2etestapp.MainActivity.java

@SuppressWarnings("unchecked")
private void refreshTestGroupsAndLog() {
    mLog = new StringBuilder();

    ArrayAdapter<TestGroup> adapter = (ArrayAdapter<TestGroup>) mTestGroupSpinner.getAdapter();
    adapter.clear();
    adapter.add(new MiscTests());
    mTestGroupSpinner.setSelection(0);//from www . j  a  v  a 2s  . co  m
    selectTestGroup(0);
}

From source file:net.willwebberley.gowertides.ui.LocationDialog.java

private void initList() {
    ListView mListView = (ListView) layoutView.findViewById(R.id.location_list);
    ArrayAdapter<Object> ad = new ArrayAdapter<Object>(getActivity(), android.R.layout.simple_list_item_1);
    mListView.setAdapter(ad);//from   w  ww .jav  a2  s.  c  o m

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            selected(i);
        }
    });

    ad.clear();
    for (int i = 0; i < names.length; i++) {
        ad.add(i + 1 + ": " + names[i]);
    }

    mListView.setAdapter(ad);
}

From source file:org.sufficientlysecure.keychain.ui.dialog.CreateKeyDialogFragment.java

private void setKeyLengthSpinnerValuesForAlgorithm(int algorithmId) {
    final ArrayAdapter<CharSequence> keySizeAdapter = (ArrayAdapter<CharSequence>) mKeySizeSpinner.getAdapter();
    final Object selectedItem = mKeySizeSpinner.getSelectedItem();
    keySizeAdapter.clear();
    switch (algorithmId) {
    case Constants.choice.algorithm.rsa:
        replaceArrayAdapterContent(keySizeAdapter, R.array.rsa_key_size_spinner_values);
        mCustomKeyInfoTextView.setText(getResources().getString(R.string.key_size_custom_info_rsa));
        break;/*www  . ja v a 2  s.c om*/
    case Constants.choice.algorithm.elgamal:
        replaceArrayAdapterContent(keySizeAdapter, R.array.elgamal_key_size_spinner_values);
        mCustomKeyInfoTextView.setText(""); // ElGamal does not support custom key length
        break;
    case Constants.choice.algorithm.dsa:
        replaceArrayAdapterContent(keySizeAdapter, R.array.dsa_key_size_spinner_values);
        mCustomKeyInfoTextView.setText(getResources().getString(R.string.key_size_custom_info_dsa));
        break;
    }
    keySizeAdapter.notifyDataSetChanged();

    // when switching algorithm, try to select same key length as before
    for (int i = 0; i < keySizeAdapter.getCount(); i++) {
        if (selectedItem.equals(keySizeAdapter.getItem(i))) {
            mKeySizeSpinner.setSelection(i);
            break;
        }
    }
}