List of usage examples for android.widget AdapterView getCount
@ViewDebug.CapturedViewProperty public int getCount()
From source file:org.openintents.historify.ui.fragments.SourcesConfigurationFragment.java
/** Called to have the fragment instantiate its user interface view. */ @Override/*from w w w .j ava2 s . co m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.fragment_sources_configuration, container, false); // init sources list mLstSources = (ListView) layout.findViewById(R.id.sources_lstSources); mLstSources.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == parent.getCount() - 1) { // need more message new WebsiteHelper().navigateToMoreInfo(getActivity()); } else { EventSource source = (EventSource) parent.getItemAtPosition(position); boolean checked = mLstSources.getCheckedItemPositions().get(position); onSourceClicked(source, checked); } } }); // sources adapter mSourcesAdapter = new SourcesAdapter(getActivity(), mLstSources); mLstSources.setAdapter(mSourcesAdapter); return layout; }
From source file:com.dwdesign.tweetings.activity.SetColorActivity.java
@Override public void onItemClick(final AdapterView<?> adapter, final View view, final int position, final long id) { if (position == adapter.getCount() - 1) { showDialog();/*w ww . ja va2 s .com*/ } else { finishSelecting(mColors.get(position)); } }
From source file:com.jbirdvegas.mgerrit.ChangelogFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mParent = this.getActivity(); mRequestQueue = Volley.newRequestQueue(mParent); mViewSwitcher = (ViewSwitcher) mParent.findViewById(R.id.vs_changelog_card); if (mViewSwitcher.getDisplayedChild() != 0) mViewSwitcher.showPrevious();//from w w w . java2 s.com mUpdatesList = (Spinner) mParent.findViewById(R.id.changelog); mSaveBtn = (ImageView) mParent.findViewById(R.id.goo_download_zip_button); mSaveBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSaveClicked(); } }); mUpdatesList.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { GooFileObject buildObject = (GooFileObject) parent.getItemAtPosition(position); GooFileObject previousBuild = null; if (position + 1 < parent.getCount()) { previousBuild = (GooFileObject) parent.getItemAtPosition(position + 1); } ((ChangelogActivity) mParent).onBuildSelected(previousBuild, buildObject); } @Override public void onNothingSelected(AdapterView<?> parent) { // Not used } }); findDates(); }
From source file:com.example.tony.popularmovie.DetailActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mTrailerAdapter = new TrailerAdapter(getActivity(), null, 0); View rootView = inflater.inflate(R.layout.fragment_detail, container, false); View headerView = LayoutInflater.from(getActivity()).inflate(R.layout.list_view_header, null); View footerView = LayoutInflater.from(getActivity()).inflate(R.layout.list_view_footer, null); mTitle = (TextView) headerView.findViewById(R.id.movie_title); mReleaseDate = (TextView) headerView.findViewById(R.id.release_date); mRatings = (TextView) headerView.findViewById(R.id.movie_ratings); mOverview = (TextView) headerView.findViewById(R.id.movie_overview); mPoster = (ImageView) headerView.findViewById(R.id.movie_poster); mCheckBox = (CheckBox) headerView.findViewById(R.id.checkBox); ListView trailerListView = (ListView) rootView.findViewById(R.id.trailer_list); trailerListView.addHeaderView(headerView); trailerListView.addFooterView(footerView); trailerListView.setAdapter(mTrailerAdapter); trailerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*w ww. ja v a 2s . co m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == parent.getCount() - 1) { Intent intent = new Intent(getActivity(), ReviewActivity.class); intent.putExtra("movieID", mMovieId); getActivity().startActivity(intent); } else { Uri uri = Uri.parse(BASE_YOUTUBE_URL + sKey); Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri); getActivity().startActivity(intent); } } }); Bundle arguments = getArguments(); if (arguments != null) { trailerListView.setVisibility(View.VISIBLE); mMovieId = arguments.getString("movieID"); } else { trailerListView.setVisibility(View.GONE); } return rootView; }
From source file:com.juick.android.ThreadFragment.java
public JuickMessage findReply(AdapterView<?> parent, int replyNo) { for (int q = 0; q < parent.getCount(); q++) { Object itemAtPosition = parent.getItemAtPosition(q); if (itemAtPosition instanceof JuickMessage) { JuickMessage maybeReplied = (JuickMessage) itemAtPosition; if (maybeReplied.getRID() == replyNo) { return maybeReplied; }//from w w w . j a v a2 s . co m } } return null; }
From source file:com.recyclerviewpulldownrefresh.view.refresh.AbPullToRefreshView.java
/** * ??/*from w ww .ja v a2 s . c om*/ * * @return */ public boolean canChildScrollDown() { if (!mEnableLoadMore) { return false; } if (mTarget instanceof AdapterView<?>) { AdapterView<?> absListView = (AdapterView<?>) mTarget; View lastChild = absListView.getChildAt(absListView.getChildCount() - 1); if (lastChild == null) { return true; } // ??viewBottom?ViewmAdapterView?view, // ViewmAdapterView?? if (lastChild.getBottom() <= getHeight() && absListView.getLastVisiblePosition() == absListView.getCount() - 1) { return true; } } else if (mTarget instanceof WebView) { WebView webview = (WebView) mTarget; return webview.getContentHeight() * webview.getScale() <= webview.getHeight() + webview.getScrollY(); } else if (mTarget instanceof ScrollView) { ScrollView scrollView = (ScrollView) mTarget; View childView = scrollView.getChildAt(0); if (childView != null) { return childView.getMeasuredHeight() <= getHeight() + mScrollView.getScrollY(); } } else if (mTarget instanceof RecyclerView) { int lastVisiblePosition = 0; View childView = null; RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (layoutManager instanceof LinearLayoutManager) { lastVisiblePosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition(); childView = layoutManager.findViewByPosition(lastVisiblePosition); } else if (layoutManager instanceof GridLayoutManager) { lastVisiblePosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition(); childView = layoutManager.findViewByPosition(lastVisiblePosition); } else if (layoutManager instanceof StaggeredGridLayoutManager) { int[] spanPosition = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()]; ((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions(spanPosition); lastVisiblePosition = getLastVisibleItemPosition(spanPosition); childView = getLastVisibleItemBottomView(layoutManager, spanPosition, lastVisiblePosition); } if (null == childView) { return false; } if (lastVisiblePosition == layoutManager.getItemCount() - 1 && childView.getBottom() + layoutManager.getBottomDecorationHeight(childView) <= mTarget.getBottom()) { return true; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } return false; }
From source file:self.philbrown.droidQuery.$.java
/** * Selects the child views of the first view in the current selection * @return a droidQuery Objects containing the child views. If the view is a subclass of * {@link AdapterView}, the {@link #data() data} of the droidQuery will be set to an Object[] * of adapter items./* w w w.j a va2 s . c o m*/ */ public $ selectChildren() { List<View> list = new ArrayList<View>(); if (view(0) instanceof AdapterView) { AdapterView<?> adapter = (AdapterView<?>) view(0); Object[] data = new Object[adapter.getCount()]; for (int i = 0; i < adapter.getCount(); i++) { data[i] = adapter.getItemAtPosition(i); } return $.with(view(0)).data(data); } else if (view(0) instanceof ViewGroup) { for (int i = 0; i < ((ViewGroup) view(0)).getChildCount(); i++) { list.add(((ViewGroup) view(0)).getChildAt(i)); } } return $.with(context, list); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
/** * ADW: Put the launcher in desktop edit mode We could be able to add, * remove and reorder screens//from www . j a v a 2s. co m */ private void startDesktopEdit() { if (!mIsEditMode) { mIsEditMode = true; final PersonaWorkspace personaWorkspace = mWorkspace; if (personaWorkspace == null) return; personaWorkspace.enableChildrenCache(0, personaWorkspace.getChildCount()); hideDesktop(true); personaWorkspace.lock(); // Load a gallery view final PersonaScreensAdapter screens = new PersonaScreensAdapter(this, personaWorkspace.getChildAt(0).getWidth(), personaWorkspace.getChildAt(0).getHeight()); for (int i = 0; i < personaWorkspace.getChildCount(); i++) { screens.addScreen((PersonaCellLayout) personaWorkspace.getChildAt(i)); } mScreensEditor = mInflater.inflate(R.layout.pr_screens_editor, null); final Gallery gal = (Gallery) mScreensEditor.findViewById(R.id.gallery_screens); gal.setCallbackDuringFling(false); gal.setClickable(false); gal.setAdapter(screens); // Setup delete button event View deleteButton = mScreensEditor.findViewById(R.id.delete_screen); deleteButton.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(View v) { final int screenToDelete = gal.getSelectedItemPosition(); if (personaWorkspace.getChildCount() > 1) { AlertDialog alertDialog = new AlertDialog.Builder(PersonaLauncher.this).create(); alertDialog.setTitle(getResources().getString(R.string.title_dialog_xml)); alertDialog.setMessage(getResources().getString(R.string.message_delete_desktop_screen)); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { personaWorkspace.removeScreen(screenToDelete); screens.removeScreen(screenToDelete); } }); alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.show(); } else { Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_delete_desktop_screen, Toast.LENGTH_LONG); t.show(); } } }); // Setup add buttons events View addLeftButton = mScreensEditor.findViewById(R.id.add_left); addLeftButton.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(View v) { if (screens.getCount() < MAX_SCREENS) { final int screenToAddLeft = gal.getSelectedItemPosition(); PersonaCellLayout newScreen = personaWorkspace.addScreen(screenToAddLeft); screens.addScreen(newScreen, screenToAddLeft); } else { Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_add_desktop_screen, Toast.LENGTH_LONG); t.show(); } } }); View addRightButton = mScreensEditor.findViewById(R.id.add_right); addRightButton.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(View v) { if (screens.getCount() < MAX_SCREENS) { final int screenToAddRight = gal.getSelectedItemPosition(); PersonaCellLayout newScreen = personaWorkspace.addScreen(screenToAddRight + 1); screens.addScreen(newScreen, screenToAddRight + 1); } else { Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_add_desktop_screen, Toast.LENGTH_LONG); t.show(); } } }); final View swapLeftButton = mScreensEditor.findViewById(R.id.swap_left); swapLeftButton.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(View v) { int currentScreen = gal.getSelectedItemPosition(); if (currentScreen > 0) { personaWorkspace.swapScreens(currentScreen - 1, currentScreen); screens.swapScreens(currentScreen - 1, currentScreen); } else { Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_swap_desktop_screen, Toast.LENGTH_LONG); t.show(); } } }); final View swapRightButton = mScreensEditor.findViewById(R.id.swap_right); swapRightButton.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(View v) { int currentScreen = gal.getSelectedItemPosition(); if (currentScreen < gal.getCount() - 1) { personaWorkspace.swapScreens(currentScreen, currentScreen + 1); screens.swapScreens(currentScreen, currentScreen + 1); } else { Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_swap_desktop_screen, Toast.LENGTH_LONG); t.show(); } } }); final View setDefaultButton = mScreensEditor.findViewById(R.id.set_default); setDefaultButton.setOnClickListener(new android.view.View.OnClickListener() { public void onClick(View v) { int currentScreen = gal.getSelectedItemPosition(); if (currentScreen < mWorkspace.getChildCount()) { mWorkspace.setDefaultScreen(currentScreen); PersonaAlmostNexusSettingsHelper.setDefaultScreen(PersonaLauncher.this, currentScreen); Toast t = Toast.makeText(PersonaLauncher.this, R.string.pref_title_default_screen, Toast.LENGTH_LONG); t.show(); } } }); gal.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position <= 0) { swapLeftButton.setVisibility(View.GONE); } else { swapLeftButton.setVisibility(View.VISIBLE); } if (position < parent.getCount() - 1) { swapRightButton.setVisibility(View.VISIBLE); } else { swapRightButton.setVisibility(View.GONE); } } public void onNothingSelected(AdapterView<?> arg0) { } }); mDragLayer.addView(mScreensEditor); } }