List of usage examples for android.widget AdapterView.OnItemLongClickListener AdapterView.OnItemLongClickListener
AdapterView.OnItemLongClickListener
From source file:com.perm.DoomPlay.VkAlbumsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_vk);//from w ww. j ava 2 s.co m listView = (ListView) findViewById(R.id.listVk); linearLoading = (LinearLayout) findViewById(R.id.linearLoading); listView.setOnItemClickListener(onClickListener); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { currentAlbum = position; startSupportActionMode(callback).setTag(position); return true; } }); if (albums == null) { getAlbums(); } else { adapter = new VkAlbumsAdapter(); listView.setAdapter(adapter); } }
From source file:org.thaliproject.nativetest.app.fragments.PeerListFragment.java
public synchronized void setListener(Listener listener) { mListener = listener;//from w w w. ja v a 2 s . c o m if (mListener != null && mListView != null) { mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int index, long l) { mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index); Log.i(TAG, "onItemClick: " + mSelectedPeerProperties.toString()); if (mListener != null) { mListener.onPeerSelected(mSelectedPeerProperties); } } }); mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int index, long l) { mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index); Log.i(TAG, "onItemLongClick: " + mSelectedPeerProperties.toString()); if (mListener != null) { mListener.onPeerSelected(mSelectedPeerProperties); } return false; // Let the event propagate } }); mListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) { mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index); Log.i(TAG, "onItemSelected: " + mSelectedPeerProperties.toString()); if (mListener != null) { mListener.onPeerSelected(mSelectedPeerProperties); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } }
From source file:net.ustyugov.jtalk.activity.note.NotesActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); service = JTalkService.getInstance(); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setTitle(R.string.notes);/*from ww w . ja v a 2s. c o m*/ getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.paged_activity); LinearLayout linear = (LinearLayout) findViewById(R.id.linear); linear.setBackgroundColor(Colors.BACKGROUND); LayoutInflater inflater = LayoutInflater.from(this); MainPageAdapter adapter = new MainPageAdapter(mPages); Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); do { final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim(); View templatePage = inflater.inflate(R.layout.list_activity, null); templatePage.setTag(account); mPages.add(templatePage); ListView list = (ListView) templatePage.findViewById(R.id.list); list.setDividerHeight(1); list.setCacheColorHint(0x00000000); list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final Note note = (Note) parent.getItemAtPosition(position); CharSequence[] items = new CharSequence[2]; items[0] = getString(R.string.Edit); items[1] = getString(R.string.Remove); AlertDialog.Builder builder = new AlertDialog.Builder(NotesActivity.this); builder.setTitle(R.string.Actions); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: createDialog(account, note); break; case 1: try { NoteManager nm = NoteManager.getNoteManager(service.getConnection(account)); nm.removeNote(note); updateNotes(); } catch (Exception ignored) { } break; } } }); builder.create().show(); return true; } }); } while (cursor.moveToNext()); cursor.close(); } mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); }
From source file:net.ustyugov.jtalk.activity.note.TemplatesActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); service = JTalkService.getInstance(); setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark); setTitle(R.string.Templates); getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.paged_activity); LinearLayout linear = (LinearLayout) findViewById(R.id.linear); linear.setBackgroundColor(Colors.BACKGROUND); LayoutInflater inflater = LayoutInflater.from(this); MainPageAdapter adapter = new MainPageAdapter(mPages); Cursor cursor = service.getContentResolver().query(JTalkProvider.ACCOUNT_URI, null, AccountDbHelper.ENABLED + " = '" + 1 + "'", null, null); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst();//from w w w. ja v a 2s . co m do { final String account = cursor.getString(cursor.getColumnIndex(AccountDbHelper.JID)).trim(); View templatePage = inflater.inflate(R.layout.list_activity, null); templatePage.setTag(account); mPages.add(templatePage); ListView list = (ListView) templatePage.findViewById(R.id.list); list.setDividerHeight(0); list.setCacheColorHint(0x00000000); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Note item = (Note) parent.getItemAtPosition(position); setResult(RESULT_OK, new Intent().putExtra("text", item.getText())); finish(); } }); list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final Note note = (Note) parent.getItemAtPosition(position); CharSequence[] items = new CharSequence[2]; items[0] = getString(R.string.Edit); items[1] = getString(R.string.Remove); AlertDialog.Builder builder = new AlertDialog.Builder(TemplatesActivity.this); builder.setTitle(R.string.Actions); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: createDialog(account, note); break; case 1: try { NoteManager nm = NoteManager.getNoteManager(service.getConnection(account)); nm.removeNote(note); updateNotes(); } catch (Exception ignored) { } break; } } }); builder.create().show(); return true; } }); } while (cursor.moveToNext()); cursor.close(); } mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setCurrentItem(0); TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator); mTitleIndicator.setTextColor(0xFF555555); mTitleIndicator.setViewPager(mPager); }
From source file:it.imwatch.nfclottery.dialogs.WinnersListDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction final Activity activity = getActivity(); if (activity == null) { Log.e(TAG, "Not attached to Activity: cannot build dialog"); return null; }/*from ww w . j a v a 2s . c o m*/ AlertDialog.Builder builder = new AlertDialog.Builder(activity); mWinnersCursor = updateWinnersCursors(); String[] inVal = new String[] { NFCMLContent.Geeks.Columns.NAME.getName(), NFCMLContent.Geeks.Columns.EMAIL.getName() }; int[] outVal = new int[] { R.id.txt_name, R.id.txt_email }; // Create the adapter and assign it to the list mWinnersAdapter = new SimpleCursorAdapter(getActivity(), R.layout.winners_row, mWinnersCursor, inVal, outVal); mWinnersAdapter.setViewBinder(new ContactsViewBinder()); LayoutInflater inflater = LayoutInflater.from(activity); final View rootView = inflater.inflate(R.layout.winners_dialog_layout, null); if (rootView == null) { Log.e(TAG, "Cannot inflate the dialog layout!"); return null; } ListView listView = (ListView) rootView.findViewById(R.id.list_winners); listView.setAdapter(mWinnersAdapter); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { showRevokeVictoryUi(position); return true; } }); TextView emptyTxt = (TextView) rootView.findViewById(android.R.id.empty); emptyTxt.setOnClickListener(mClickListener); listView.setEmptyView(emptyTxt); builder.setView(rootView); mSwitcher = (ViewSwitcher) rootView.findViewById(R.id.switcher); Button btn_cancel = (Button) mSwitcher.findViewById(R.id.btn_cancel); btn_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { endRevokeVictory(); } }); Button btn_revoke = (Button) mSwitcher.findViewById(R.id.btn_revoke); btn_revoke.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { revokeVictory(); } }); Button btn_ok = (Button) mSwitcher.findViewById(android.R.id.button1); btn_ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final Dialog thisDialog = WinnersListDialog.this.getDialog(); if (thisDialog != null) { thisDialog.cancel(); } else { Log.w(TAG, "Can't get the Dialog instance."); } } }); // Create the AlertDialog object and return it return builder.create(); }
From source file:org.cvasilak.jboss.mobile.admin.fragments.DeploymentsViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log.d(TAG, "@onActivityCreated()"); // Define the contextual action mode //registerForContextMenu(getListView()); getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override//from w ww. ja v a 2 s . co m public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (mActionMode != null) { return false; } selectedItemPos = position; getListView().setItemChecked(position, true); // Start the CAB using the ActionMode.Callback defined above mActionMode = getSherlockActivity().startActionMode(new ActionModeCallback()); return true; } }); refresh(); }
From source file:org.cvasilak.jboss.mobile.app.fragments.DeploymentsViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log.d(TAG, "@onActivityCreated()"); ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar(); bar.setTitle((mode == Mode.DOMAIN_MODE ? getString(R.string.repository) : getString(R.string.deployments))); // Define the contextual action mode getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override/*w w w. j a va 2 s. co m*/ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (mActionMode != null) { return false; } selectedItemPos = position; getListView().setItemChecked(position, true); // Start the CAB using the ActionMode.Callback defined above mActionMode = ((ActionBarActivity) getActivity()).startSupportActionMode(new ActionModeCallback()); return true; } }); setListAdapter(new DeploymentAdapter(deployments)); refresh(); }
From source file:org.starfishrespect.myconsumption.android.ui.ChartChoiceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_chart_choice, container, false); // Register to the EventBus EventBus.getDefault().register(this); listViewSensor = (ListView) view.findViewById(R.id.listViewSensors); mLinearLayout = (LinearLayout) view.findViewById(R.id.linearLayoutDateSelectionItems); mTextView = (TextView) view.findViewById(R.id.textViewUsername); spinnerDate = (Spinner) view.findViewById(R.id.spinnerDate); spinnerFrequency = (Spinner) view.findViewById(R.id.spinnerFrequency); spinnerPrecision = (Spinner) view.findViewById(R.id.spinnerPrecision); seekBar = (SeekBar) view.findViewById(R.id.seekBar); seekBarPosition = 0;//from w w w .ja va 2 s . c o m seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { // Called when the slider moves to another value @Override public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) { seekBarPosition = progresValue; } // Called when you start moving the slider @Override public void onStartTrackingTouch(SeekBar seekBar) { } // Called when it seems that you are done moving the slider @Override public void onStopTrackingTouch(SeekBar seekBar) { // Tell ChartViewFragment to update the graph EventBus.getDefault().post(new UpdateMovingAverageEvent(seekBarPosition)); } }); listViewSensor.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { lastLongClickItem = position; PopupMenu popup = new PopupMenu(mActivity, view); popup.inflate(R.menu.menu_sensor_dropdown); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_delete_sensor: if (!MiscFunctions.isOnline(mActivity)) { MiscFunctions.makeOfflineDialog(mActivity).show(); return false; } deleteSensor(lastLongClickItem); break; case R.id.action_edit_sensor: if (!MiscFunctions.isOnline(mActivity)) { MiscFunctions.makeOfflineDialog(mActivity).show(); return false; } editSensor(lastLongClickItem); break; } return false; } }); popup.show(); return false; } }); return view; }
From source file:com.perm.DoomPlay.ListVkActivity.java
private void initializeUi() { listView = (ListView) findViewById(R.id.listAllSongs); listView.setOnItemClickListener(onItemTrackClick); if (currentAction.equals(actionMyMusic) || currentAction.equals(actionMyAlbums)) { listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override//from w w w . ja v a 2 s. co m public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startSupportActionMode(callback).setTag(position); return true; } }); } else listView.setOnItemLongClickListener(onItemLongVkListener); linearControls = (RelativeLayout) findViewById(R.id.linearControls); intentService = new Intent(this, PlayingService.class); intentService.setAction(PlayingService.actionOnline); imgPlay = (ImageView) findViewById(R.id.imagePlay); imgShuffle = (ImageView) findViewById(R.id.imageShuffle); imgRepeat = (ImageView) findViewById(R.id.imageRepeat); imgNext = (ImageView) findViewById(R.id.imageNext); imgPrevious = (ImageView) findViewById(R.id.imagePrevious); seekBar = (SeekBar) findViewById(R.id.seek_bar); textCurrentTime = (TextView) findViewById(R.id.textElapsed); textTotalTime = (TextView) findViewById(R.id.textDuration); linearLoading = (LinearLayout) findViewById(R.id.linearLoading); }
From source file:org.sensapp.android.sensappdroid.activities.GraphDisplayerActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.graph_displayer); List<String> data = getIntent().getData().getPathSegments(); graphName = data.get(data.size() - 1); graphID = Long.parseLong(data.get(data.size() - 2)); setTitle(graphName);/*from www . j a v a 2s .c o m*/ ListView list = (ListView) findViewById(R.id.list_graph_displayer); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { GraphWrapper gw = (GraphWrapper) adapterView.getItemAtPosition(i); Callable<Integer> refreshGraphs = new Callable<Integer>() { public Integer call() { return displayGraphs(); } }; GraphSensorOptionsDialogFragment.newInstance(gw.getID(), gw.getName(), refreshGraphs) .show(getSupportFragmentManager(), "newOptionEditor"); } }); list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) { GraphWrapper gw = (GraphWrapper) adapterView.getItemAtPosition(i); String where = SensAppContract.GraphSensor.ID + " = \"" + gw.getID() + "\" AND " + SensAppContract.GraphSensor.GRAPH + " = " + graphID; getApplication().getContentResolver().delete(SensAppContract.GraphSensor.CONTENT_URI, where, null); displayGraphs(); return true; } }); getSupportLoaderManager().initLoader(0, null, this); displayGraphs(); }