List of usage examples for android.widget ListAdapter getCount
int getCount();
From source file:org.kontalk.ui.ConversationList.java
@Override public boolean onSearchRequested() { ConversationListFragment fragment = getListFragment(); ListAdapter list = fragment.getListAdapter(); // no data found if (list == null || list.getCount() == 0) return false; startSearch(null, false, null, false); return true;/*from ww w . ja v a 2 s. co m*/ }
From source file:de.tum.in.tumcampus.fragments.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); mContext = getActivity();// w ww .j a va 2 s. c om // Disables silence service if the app is used without TUMOnline access CheckBoxPreference silent = (CheckBoxPreference) findPreference("silent_mode"); if (!new AccessTokenManager(mContext).hasValidAccessToken()) { silent.setEnabled(false); } // Click listener for preference list entries. Used to simulate a button // (since it is not possible to add a button to the preferences screen) findPreference("button_wizard").setOnPreferenceClickListener(this); findPreference("button_clear_cache").setOnPreferenceClickListener(this); findPreference("facebook").setOnPreferenceClickListener(this); findPreference("github").setOnPreferenceClickListener(this); findPreference("first_run").setOnPreferenceClickListener(this); findPreference("licenses").setOnPreferenceClickListener(this); findPreference("feedback").setOnPreferenceClickListener(this); findPreference("privacy").setOnPreferenceClickListener(this); // Set summary for these preferences setSummary("card_cafeteria_default_G"); setSummary("card_cafeteria_default_K"); setSummary("card_cafeteria_default_W"); setSummary("card_role"); setSummary("card_stations_default_G"); setSummary("card_stations_default_C"); setSummary("card_stations_default_K"); setSummary("card_default_campus"); setSummary("silent_mode_set_to"); setSummary("background_mode_set_to"); // Register the change listener to react immediately on changes PreferenceManager.getDefaultSharedPreferences(mContext).registerOnSharedPreferenceChangeListener(this); // Populate news sources populateNewsSources(); // Open a card's preference screen if selected from it's context menu Bundle bundle = getArguments(); if (bundle != null && bundle.containsKey(Const.PREFERENCE_SCREEN)) { final String key = bundle.getString(Const.PREFERENCE_SCREEN); PreferenceScreen screen = (PreferenceScreen) findPreference("cards_pref_container"); final PreferenceScreen cardPreferenceScreen = (PreferenceScreen) findPreference(key); cardPreferenceScreen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { initializeActionBar(cardPreferenceScreen); return true; } }); final ListAdapter listAdapter = screen.getRootAdapter(); final int itemsCount = listAdapter.getCount(); for (int i = 0; i < itemsCount; ++i) { if (listAdapter.getItem(i).equals(cardPreferenceScreen)) { screen.onItemClick(null, null, i, 0); break; } } } }
From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionListFragment.java
private void showDatesWithEvents(CaldroidFragment caldroid) { ListAdapter adapter = getListAdapter(); int count = adapter.getCount(); ColorDrawable orange = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.holo_orange_dark)); RecurringTransaction tx = RecurringTransaction.createInstance(); for (int i = 0; i < count; i++) { Cursor cursor = (Cursor) adapter.getItem(i); tx.loadFromCursor(cursor);//w w w . ja v a2s . c o m caldroid.setBackgroundDrawableForDate(orange, tx.getPaymentDate()); } }
From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterListView.java
int findCurrentHeaderPosition(int fromPosition) { ListAdapter adapter = getAdapter(); if (fromPosition >= adapter.getCount()) return -1; // dataset has changed, no candidate // Only need to look through to the next section item above for (int position = fromPosition; position >= 0; position--) { int viewType = adapter.getItemViewType(position); if (isItemSticky(adapter, viewType)) return position; }/* w w w . ja v a 2 s.co m*/ return -1; }
From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterListView.java
void recreateStickyShadow() { destroyStickyShadow();/*from w ww. j ava2 s. c o m*/ ListAdapter adapter = getAdapter(); if (adapter != null && adapter.getCount() > 0) { int firstVisiblePosition = getFirstVisiblePosition(); int headerPosition = findCurrentHeaderPosition(firstVisiblePosition); if (headerPosition == -1) { return; } tryCreateShadowAtPosition(headerPosition, firstVisiblePosition, getLastVisiblePosition() - firstVisiblePosition + 1); } }
From source file:at.alladin.rmbt.android.views.ResultQoSDetailView.java
@SuppressWarnings("unchecked") @Override/*ww w . j av a 2s . c om*/ public void taskEnded(JSONArray result) { System.out.println("ResultQoSDetail taskEnded"); this.testResult = result; if (resultFetchEndTaskListener != null) { resultFetchEndTaskListener.taskEnded(result); } ProgressBar resultProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar); TextView resultTextView = (TextView) view.findViewById(R.id.info_text); try { results = new QoSServerResultCollection(result); View successList = view.findViewById(R.id.qos_success_list); List<HashMap<String, String>> itemList = new ArrayList<HashMap<String, String>>(); int index = 0; for (QoSTestResultEnum type : QoSTestResultEnum.values()) { if (results.getQoSStatistics().getTestCounter(type) > 0) { HashMap<String, String> listItem = new HashMap<String, String>(); listItem.put("name", ConfigHelper.getCachedQoSNameByTestType(type, activity)); listItem.put("type_name", type.toString()); listItem.put("index", String.valueOf(index++)); itemList.add(listItem); } } ListAdapter valueList = new SimpleAdapter(activity, itemList, R.layout.qos_category_list_item, new String[] { "name" }, new int[] { R.id.name }); resultProgressBar.setVisibility(View.GONE); if (valueList.getCount() > 0) { //in case the view will change again: if (ListView.class.isAssignableFrom(successList.getClass())) { ((ListView) successList).setAdapter(valueList); ((ListView) successList).setOnItemClickListener(this); } else { ViewGroup vgList = (ViewGroup) successList; for (int i = 0; i < valueList.getCount(); i++) { View v = valueList.getView(i, null, null); QoSTestResultEnum key = QoSTestResultEnum .valueOf(((HashMap<String, String>) valueList.getItem(i)).get("type_name")); if (results.getQoSStatistics().getFailureCounter(key) > 0) { ImageView img = (ImageView) v.findViewById(R.id.status); img.setImageResource(R.drawable.traffic_lights_red); } TextView status = (TextView) v.findViewById(R.id.qos_type_status); status.setText((results.getQoSStatistics().getTestCounter(key) - results.getQoSStatistics().getFailedTestsCounter(key)) + "/" + results.getQoSStatistics().getTestCounter(key)); v.setOnClickListener(this); v.setTag(valueList.getItem(i)); vgList.addView(v); } } successList.invalidate(); resultTextView.setVisibility(View.GONE); successList.setVisibility(View.VISIBLE); } else { resultTextView.setText(R.string.result_qos_error_no_data_available); } } catch (Throwable t) { resultTextView.setText(R.string.result_qos_error_no_data_available); resultProgressBar.setVisibility(View.GONE); t.printStackTrace(); } }
From source file:de.damdi.fitness.activity.start_training.DialogFragmentAddEntry.java
private void setWeightValue(int value) { // this is not a very elegant solution but it should work ListAdapter adapter = (ListAdapter) spinner_weight.getAdapter(); for (int i = 0; i < adapter.getCount() - 1; i++) { String str = ((String) spinner_weight.getItemAtPosition(i)); str = str.substring(0, str.length() - 3); str = str.replaceAll(",", "."); float floatingNumber = Float.parseFloat(str); floatingNumber *= 1000; // convert kg to g int val = (int) floatingNumber; if (val == value) { spinner_weight.setSelection(i); return; }/*from www .ja va2 s . c o m*/ } Log.e(TAG, "Could not set weight value: " + value); }
From source file:com.bamalearn.bamalearnburmese.DrawerMainActivity.java
public void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return;/*from ww w. j a v a 2 s . com*/ } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) listItem.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT, AbsListView.LayoutParams.WRAP_CONTENT)); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutParams(params); }
From source file:android.support.v7.internal.widget.ListViewCompat.java
/** * Find a position that can be selected (i.e., is not a separator). * * @param position The starting position to look at. * @param lookDown Whether to look down for other positions. * @return The next selectable position starting at position and then searching either up or * down. Returns {@link #INVALID_POSITION} if nothing can be found. *//*from w w w .ja v a 2s . c o m*/ public int lookForSelectablePosition(int position, boolean lookDown) { final ListAdapter adapter = getAdapter(); if (adapter == null || isInTouchMode()) { return INVALID_POSITION; } final int count = adapter.getCount(); if (!getAdapter().areAllItemsEnabled()) { if (lookDown) { position = Math.max(0, position); while (position < count && !adapter.isEnabled(position)) { position++; } } else { position = Math.min(position, count - 1); while (position >= 0 && !adapter.isEnabled(position)) { position--; } } if (position < 0 || position >= count) { return INVALID_POSITION; } return position; } else { if (position < 0 || position >= count) { return INVALID_POSITION; } return position; } }
From source file:com.dm.xz.views.PinnedSectionListView.java
void recreatePinnedShadow() { destroyPinnedShadow();//from w w w .ja v a 2s . com ListAdapter adapter = getAdapter(); if (adapter != null && adapter.getCount() > 0) { int firstVisiblePosition = getFirstVisiblePosition(); int sectionPosition = findCurrentSectionPosition(firstVisiblePosition); if (sectionPosition == -1) return; // no views to pin, exit ensureShadowForPosition(sectionPosition, firstVisiblePosition, getLastVisiblePosition() - firstVisiblePosition); } }