Java Code Examples for android.widget.ListView#getItemAtPosition()
The following examples show how to use
android.widget.ListView#getItemAtPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountsSettingsFragment.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
@Override public void onClick(final DialogInterface dialog, final int which) { final String oldAccount = getSignedInAccountName(); switch (which) { case DialogInterface.BUTTON_POSITIVE: // Signed in final ListView lv = ((AlertDialog)dialog).getListView(); final String newAccount = (String) lv.getItemAtPosition(lv.getCheckedItemPosition()); getSharedPreferences() .edit() .putString(PREF_ACCOUNT_NAME, newAccount) .apply(); AccountStateChangedListener.onAccountSignedIn(oldAccount, newAccount); if (mDependentPreference != null) { mDependentPreference.setChecked(true); } break; case DialogInterface.BUTTON_NEUTRAL: // Signed out AccountStateChangedListener.onAccountSignedOut(oldAccount); getSharedPreferences() .edit() .remove(PREF_ACCOUNT_NAME) .apply(); break; } }
Example 2
Source File: MainActivity.java From dex-hdog with MIT License | 6 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ListView listView = (ListView) parent; AppInfo appInfo = (AppInfo) listView.getItemAtPosition(position); String packageName = appInfo.getPackageName(); String appName = appInfo.getAppName(); Log.d(TAG, packageName); if(!JniUtil.isRunning(packageName)){ openApp(packageName); } Log.d(TAG, "Create folder:" + FileUtil.createPath(HDOG_PATH +File.separator + packageName + File.separator + TYPE_DEX)); Log.d(TAG, "Create folder:" + FileUtil.createPath(HDOG_PATH +File.separator + packageName + File.separator + TYPE_DEY)); Intent intent = new Intent(this, DumpActivity.class); intent.putExtra("package_name", packageName); intent.putExtra("app_name", appName); startActivity(intent); }
Example 3
Source File: ResultActivityTest.java From aedict with GNU General Public License v3.0 | 6 votes |
public void testEdictExternSearch() throws Exception { final Intent i = new Intent(getInstrumentation().getContext(), ResultActivity.class); i.setAction(ResultActivity.EDICT_ACTION_INTERCEPT); i.putExtra(ResultActivity.EDICT_INTENTKEY_KANJIS, "空白"); tester.startActivity(i); assertTrue(tester.getText(R.id.textSelectedDictionary).contains("Default")); final ListView lv = getActivity().getListView(); assertEquals(1, lv.getCount()); DictEntry entry = (DictEntry) lv.getItemAtPosition(0); assertEquals("Searching", entry.english); Thread.sleep(500); final Intent i2 = getStartedActivityIntent(); final List<DictEntry> result = (List<DictEntry>) i2.getSerializableExtra(ResultActivity.INTENTKEY_RESULT_LIST); entry = result.get(0); assertEquals("(adj-na,n,adj-no) blank space/vacuum/space/null (NUL)/(P)", entry.english); assertEquals("空白", entry.getJapanese()); assertEquals("くうはく", entry.reading); assertEquals(1, result.size()); }
Example 4
Source File: AccountsSettingsFragment.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
@Override public void onClick(final DialogInterface dialog, final int which) { final String oldAccount = getSignedInAccountName(); switch (which) { case DialogInterface.BUTTON_POSITIVE: // Signed in final ListView lv = ((AlertDialog)dialog).getListView(); final String newAccount = (String) lv.getItemAtPosition(lv.getCheckedItemPosition()); getSharedPreferences() .edit() .putString(PREF_ACCOUNT_NAME, newAccount) .apply(); AccountStateChangedListener.onAccountSignedIn(oldAccount, newAccount); if (mDependentPreference != null) { mDependentPreference.setChecked(true); } break; case DialogInterface.BUTTON_NEUTRAL: // Signed out AccountStateChangedListener.onAccountSignedOut(oldAccount); getSharedPreferences() .edit() .remove(PREF_ACCOUNT_NAME) .apply(); break; } }
Example 5
Source File: MainActivity2.java From wakao-app with MIT License | 6 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ListView lv = (ListView) parent; CategoryItem item = (CategoryItem) lv.getItemAtPosition(position); switch (item.getIcon()) { case R.drawable.xiao: fragmentChange(R.id.toFunny); break; case R.drawable.zhang: fragmentChange(R.id.toArticle); break; case R.drawable.qiu: fragmentChange(R.id.toArticle_NBA); break; case R.drawable.girl: fragmentChange(R.id.toGirl); break; default: break; } }
Example 6
Source File: AccountsSettingsFragment.java From Android-Keyboard with Apache License 2.0 | 6 votes |
@Override public void onClick(final DialogInterface dialog, final int which) { final String oldAccount = getSignedInAccountName(); switch (which) { case DialogInterface.BUTTON_POSITIVE: // Signed in final ListView lv = ((AlertDialog)dialog).getListView(); final String newAccount = (String) lv.getItemAtPosition(lv.getCheckedItemPosition()); getSharedPreferences() .edit() .putString(PREF_ACCOUNT_NAME, newAccount) .apply(); AccountStateChangedListener.onAccountSignedIn(oldAccount, newAccount); if (mDependentPreference != null) { mDependentPreference.setChecked(true); } break; case DialogInterface.BUTTON_NEUTRAL: // Signed out AccountStateChangedListener.onAccountSignedOut(oldAccount); getSharedPreferences() .edit() .remove(PREF_ACCOUNT_NAME) .apply(); break; } }
Example 7
Source File: AlertList.java From NightWatch with GNU General Public License v3.0 | 6 votes |
@Override public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position, final long id) { ListView lv = (ListView) parent; @SuppressWarnings("unchecked") HashMap<String, String> item = (HashMap<String, String>) lv.getItemAtPosition(position); Log.d(TAG, "Item clicked " + lv.getItemAtPosition(position) + item.get("uuid")); //The XML for each item in the list (should you use a custom XML) must have android:longClickable="true" // as well (or you can use the convenience method lv.setLongClickable(true);). This way you can have a list // with only some items responding to longclick. (might be used for non removable alerts) Intent myIntent = new Intent(AlertList.this, EditAlertActivity.class); myIntent.putExtra("uuid", item.get("uuid")); //Optional parameters AlertList.this.startActivityForResult(myIntent, EDIT_ALERT); return true; }
Example 8
Source File: ConversationPage.java From fanfouapp-opensource with Apache License 2.0 | 5 votes |
@Override public void onItemClick(final ListView view, final View row, final int position) { final Status s = (Status) view.getItemAtPosition(position); if (s != null) { CommonHelper.goStatusPage(this.mContext, s); } }
Example 9
Source File: PopupListFragment.java From android-ActionBarCompat-ListPopupMenu with Apache License 2.0 | 5 votes |
@Override public void onListItemClick(ListView listView, View v, int position, long id) { String item = (String) listView.getItemAtPosition(position); // Show a toast if the user clicks on an item Toast.makeText(getActivity(), "Item Clicked: " + item, Toast.LENGTH_SHORT).show(); }
Example 10
Source File: HomeActivity.java From AndroidUiKit with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") protected void onListItemClick(ListView l, View v, int position, long id) { Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position); Intent intent = new Intent((Intent) map.get("intent")); intent.addCategory(APP_CAGEGORY); startActivity(intent); }
Example 11
Source File: ComponentListActivity.java From Virtualview-Android with MIT License | 5 votes |
@Override protected void onListItemClick(ListView l, View v, int position, long id) { Map<String, String> item = (Map<String, String>)l.getItemAtPosition(position); String className = item.get("class"); Intent intent = new Intent(); intent.setComponent(new ComponentName(this, className)); intent.putExtra("name", item.get("name")); intent.putExtra("data", item.get("data")); startActivity(intent); }
Example 12
Source File: ApiDemos.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@Override @SuppressWarnings("unchecked") protected void onListItemClick(ListView l, View v, int position, long id) { Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position); Intent intent = (Intent) map.get("intent"); startActivity(intent); }
Example 13
Source File: TopicsListFragment.java From android-discourse with Apache License 2.0 | 5 votes |
@Override public void onListItemClick(ListView l, View v, int position, long id) { Topic t = (Topic) l.getItemAtPosition(position); if (t == null) { return; } ActivityUtils.startTopicActivity(getActivity(), t.slug, t.id); }
Example 14
Source File: SelectionFragment.java From KlyphMessenger with MIT License | 5 votes |
@Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); PRosterEntry p = (PRosterEntry) l.getItemAtPosition(position); Friend friend = new Friend(); friend.setUid(p.getId()); friend.setName(p.getName()); listener.onFriendSelected(friend); }
Example 15
Source File: Support7Demos.java From V.FlyoutTest with MIT License | 5 votes |
@Override @SuppressWarnings("unchecked") protected void onListItemClick(ListView l, View v, int position, long id) { Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position); Intent intent = (Intent) map.get("intent"); startActivity(intent); }
Example 16
Source File: DemoListActivity.java From Tangram-Android with MIT License | 5 votes |
@Override protected void onListItemClick(ListView l, View v, int position, long id) { Map<String, String> item = (Map<String, String>)l.getItemAtPosition(position); String className = item.get("class"); if (className != null) { Intent intent = new Intent(); intent.setComponent(new ComponentName(this, className)); startActivity(intent); } }
Example 17
Source File: FileListViewFragmentBase.java From edslite with GNU General Public License v2.0 | 5 votes |
protected boolean haveSelectedFiles() { ListView lv = getListView(); int count = lv.getCount(); for(int i=0; i<count;i++) { BrowserRecord file = (BrowserRecord) lv.getItemAtPosition(i); if (file.isSelected()) return true; } return false; }
Example 18
Source File: SamplesActivity.java From android-oauth-client with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") protected void onListItemClick(ListView l, View v, int position, long id) { Map<String, Object> map = (Map<String, Object>) l .getItemAtPosition(position); Intent intent = (Intent) map.get("intent"); startActivity(intent); }
Example 19
Source File: FileListViewFragmentBase.java From edslite with GNU General Public License v2.0 | 5 votes |
protected ArrayList<BrowserRecord> getSelectedFiles() { ArrayList<BrowserRecord> selectedRecordsList = new ArrayList<>(); ListView lv = getListView(); int count = lv.getCount(); for(int i=0; i<count;i++) { BrowserRecord file = (BrowserRecord) lv.getItemAtPosition(i); if (file.isSelected()) selectedRecordsList.add(file); } return selectedRecordsList; }
Example 20
Source File: MediaFragment.java From onpc with GNU General Public License v3.0 | 4 votes |
@Override public void onCreateContextMenu(@NonNull ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { selectedItem = null; if (v.getId() == listView.getId() && activity.isConnected()) { final State state = activity.getStateManager().getState(); final ReceiverInformationMsg.Selector selector = state.getActualSelector(); final ReceiverInformationMsg.NetworkService networkService = state.getNetworkService(); if (selector != null) { Logging.info(this, "Context menu for selector " + selector.toString() + (networkService != null ? " and service " + networkService.toString() : "")); ListView lv = (ListView) v; AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) menuInfo; final Object item = lv.getItemAtPosition(acmi.position); if (item instanceof XmlListItemMsg) { selectedItem = (XmlListItemMsg) item; MenuInflater inflater = activity.getMenuInflater(); inflater.inflate(R.menu.playlist_context_menu, menu); final boolean isQueue = state.serviceType == ServiceType.PLAYQUEUE; final boolean addToQueue = selector.isAddToQueue() || (networkService != null && networkService.isAddToQueue()); final boolean isAdvQueue = activity.getConfiguration().isAdvancedQueue(); if (isQueue || addToQueue) { menu.setHeaderTitle(R.string.playlist_options); } menu.findItem(R.id.playlist_menu_add).setVisible(!isQueue && addToQueue); menu.findItem(R.id.playlist_menu_add_and_play).setVisible(!isQueue && addToQueue); menu.findItem(R.id.playlist_menu_replace).setVisible(!isQueue && addToQueue && isAdvQueue); menu.findItem(R.id.playlist_menu_replace_and_play).setVisible(!isQueue && addToQueue && isAdvQueue); menu.findItem(R.id.playlist_menu_remove).setVisible(isQueue); menu.findItem(R.id.playlist_menu_remove_all).setVisible(isQueue); menu.findItem(R.id.playlist_menu_move_from).setVisible(isQueue); menu.findItem(R.id.playlist_menu_move_to).setVisible( isQueue && isMoveToValid(selectedItem.getMessageId())); final boolean isTrackMenu = state.trackMenu == MenuStatusMsg.TrackMenu.ENABLE; final boolean isPlaying = selectedItem.getIcon() == XmlListItemMsg.Icon.PLAY; menu.findItem(R.id.playlist_track_menu).setVisible(isTrackMenu && isPlaying && !isQueue); menu.findItem(R.id.cmd_playback_mode).setVisible(isPlaying && !state.isPlaybackMode()); } } } }