Java 类android.widget.AdapterView.OnItemLongClickListener 实例源码

项目:Android-Fitness    文件:FoodActivity.java   
private void setListLongClick() {
    this.result_nutrientList.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {

                new AlertDialog.Builder(FoodActivity.this)
                        .setItems(R.array.menu_food, new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                        String[] PK = getResources().getStringArray(R.array.menu_food);
                                        if(PK[which].equals("ɾ����ʳ����Ϣ")) {
                                            showDeleteDialog();
                                        }
                                }
                        }).show();
                return true;
       }
    });
}
项目:Android-Fitness    文件:DietActivity.java   
private void itemOnLongClick() {
    this.listview.setOnItemLongClickListener(new OnItemLongClickListener() {
                        @Override
                        public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {

                                new AlertDialog.Builder(DietActivity.this)
                                        .setItems(R.array.menu_diet, new DialogInterface.OnClickListener() {
                                                public void onClick(DialogInterface dialog, int which) {
                                                        String[] PK = getResources().getStringArray(R.array.menu_diet);
                                                        if(PK[which].equals("ɾ��������¼")) {
                                                               //Log.i("test", "itemDelete:"+position);
                                                               itemDelete(position);
                                                        }
                                                }
                                        }).show();
                                return true;
                       }
    });
}
项目:yun2win-sdk-android    文件:AppBrowser.java   
private void initView() {
    mView = mInflater.inflate(R.layout.apk_browser, null);
    mListView = (GridView) mView.findViewById(R.id.gvApkList);
    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @SuppressLint("NewApi")
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            /*
             * FileItemForOperation fileItem =
             * mData.getFileItems().get(arg2); xtemp = arg1.getX(); ytemp
             * =arg1.getY(); fileItem.getFileItem().setXlocation(xtemp);
             * fileItem.getFileItem().setYlocation(ytemp);
             * BrowerItemLongclick(fileItem);
             */
            return true;
        }
    });
}
项目:yun2win-sdk-android    文件:OAFileBrowser.java   
private void initView() {
    mView = mInflater.inflate(R.layout.video_browser, null);
    mListView = (ListView) mView.findViewById(R.id.lvVideoList);
    mListView.setOnItemClickListener(this);
    mGridView = (GridView) mView.findViewById(R.id.gvVideoList);
    mGridView.setOnItemClickListener(this);
    mGridView.setNumColumns(ScreenWidgh / 160);
    mGridView.setVisibility(View.GONE);
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @SuppressLint("NewApi")
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            /*
             * FileItemForOperation fileItem =
             * mData.getFileItems().get(arg2); xtemp = arg1.getX(); ytemp
             * =arg1.getY(); fileItem.getFileItem().setXlocation(xtemp);
             * fileItem.getFileItem().setYlocation(ytemp);
             * VideoBrowerItemLongclick(fileItem);
             */
            return true;
        }
    });
}
项目:yun2win-sdk-android    文件:VideoFileBrowser.java   
private void initView() {
    mView = mInflater.inflate(R.layout.video_browser, null);
    mListView = (ListView) mView.findViewById(R.id.lvVideoList);
    mListView.setOnItemClickListener(this);
    mGridView = (GridView) mView.findViewById(R.id.gvVideoList);
    mGridView.setOnItemClickListener(this);
    mGridView.setNumColumns(ScreenWidgh / 160);
    mGridView.setVisibility(View.GONE);
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @SuppressLint("NewApi")
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            /*
             * FileItemForOperation fileItem =
             * mData.getFileItems().get(arg2); xtemp = arg1.getX(); ytemp
             * =arg1.getY(); fileItem.getFileItem().setXlocation(xtemp);
             * fileItem.getFileItem().setYlocation(ytemp);
             * VideoBrowerItemLongclick(fileItem);
             */
            return true;
        }
    });
}
项目:yun2win-sdk-android    文件:MusicFileBrowser.java   
private void initView() {
    mView = mInflater.inflate(R.layout.music_browser, null);
    mListView = (ListView) mView.findViewById(R.id.lvMusicList);
    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @SuppressLint("NewApi")
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) {
            /*
             * FileItemForOperation fileItem =
             * mData.getFileItems().get(arg2); xtemp = arg1.getX(); ytemp
             * =arg1.getY(); fileItem.getFileItem().setXlocation(xtemp);
             * fileItem.getFileItem().setYlocation(ytemp);
             * MusicBrowerItemLongclick(fileItem);
             */
            return true;
        }
    });
}
项目:spidey    文件:ScansActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setTitle(R.string.history_of_spidey_scans);

    mDb = DatabaseHelper.getInstance(this);
    List<Scan> scans = mDb.getAllScans();

    mListView = getListView();

    //add on long click listener to start action mode
    getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
            onListItemCheck(position);
            return true;
        }
    });

 // use the SimpleCursorAdapter to show the
    // elements in a ListView
    ScanAdapter adapter = new ScanAdapter(this,scans);
    setListAdapter(adapter);

}
项目:AccountPasswordsAndroid    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    myApp = (MyApplication) getApplication();
    setContentView(R.layout.activity_main);
    myActivity = this;
    mContext = this;
    myApp.setUrlVing();
    myApp.setPostUrlVing();
    Button saveBtn = (Button)findViewById(R.id.saveBtn);
    myApp.saveStuff(mContext, saveBtn);
    adapter = new PasswordListAdapter(mContext,android.R.layout.simple_list_item_2,myApp.getExpArray());
    listView = (ListView) findViewById(R.id.passwordDataList);
       listView.setAdapter(adapter);
       listView.setOnItemClickListener((OnItemClickListener) mContext);
       listView.setOnItemLongClickListener((OnItemLongClickListener) mContext);
       myApp.setExpandAdapter(adapter);
    ReadKeyFiles readRSATask = new ReadKeyFiles(myActivity, mContext);
    readRSATask.execute(myApp);
}
项目:android_programmering_2014    文件:ShowListActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    datasource = new ShowDataSource(this);
    datasource.open();

    ListView listView = getListView();
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
            deleteShowDialog(position);
            return true;
           }
    });

    List<Show> shows = datasource.getAllShows();

    ShowListAdapter adapter = new ShowListAdapter(this, android.R.layout.simple_list_item_1);
    setListAdapter(adapter);
    adapter.addAll(shows);
}
项目:RssReader    文件:ChannelListFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState){
    super.onActivityCreated(savedInstanceState);

    // Set the ListView's long click listener.
    getListView().setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> listView, View view,
                int position, long id) {
            if (mChannelLongClickListener != null) {
                getListView().setItemChecked(position, true);
                mChannelLongClickListener.onChannelLongClicked(position);
                return true;
            }
            return false;
        }
    });
}
项目:iSCAU-Android    文件:CaldroidFragment.java   
/**
 * Callback to listener when date is valid (not disable, not outside of
 * min/max date)
 * 
 * @return
 */
private OnItemLongClickListener getDateItemLongClickListener() {
    dateItemLongClickListener = new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                int position, long id) {

            DateTime dateTime = dateInMonthsList.get(position);

            if (caldroidListener != null) {
                if ((minDateTime != null && dateTime.lt(minDateTime))
                        || (maxDateTime != null && dateTime.gt(maxDateTime))
                        || (disableDates != null && disableDates
                                .indexOf(dateTime) != -1)) {
                    return false;
                }
                Date date = CalendarHelper.convertDateTimeToDate(dateTime);
                caldroidListener.onLongClickDate(date, view);
            }

            return true;
        }
    };

    return dateItemLongClickListener;
}
项目:omni-note    文件:DriveActivity.java   
@Override
public void onResult(MetadataBufferResult result) {
    if (!result.getStatus().isSuccess()) {
        showMessage("Problem while retrieving files");
        return;
    }
    mDriveResultsAdapter.setData(result.getMetadataBuffer());
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent,
                View view, int position, long id) {
            Metadata metadata = mDriveResultsAdapter.getItem(position);
            StringBuilder sb = new StringBuilder();
            sb.append(metadata.getTitle() + "\n")
            .append(metadata.getMimeType() + "\n")
            .append(metadata.getFileSize() + "\n")
            .append(metadata.getCreatedDate() + "\n")
            .append(metadata.getModifiedDate() + "\n");
            showMessage(sb.toString());

            return false;
        }
    });
}
项目:qsolution    文件:TabSurveyAudit.java   
private void loadListPosm() {
    posms.clear();
    outletPosm = new TtDKunjunganSurveyorOutletPosm();
    outletPosm.setKode(outlet.getKode());
    posms = outletPosmDao.listByExample(outletPosm);
    adapter = new PosmOutletAdapter(this, posms);
    lsOutletPosm.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    lsOutletPosm.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
            outletPosm = new TtDKunjunganSurveyorOutletPosm();
            outletPosm = posms.get(index);
            outletPosmDao.delete(outletPosm.getId());
            Toast.makeText(getApplicationContext(), "Outlet posm berhasil dihapus", Toast.LENGTH_LONG).show();
            loadListPosm();
            return false;
        }
    });
}
项目:qsolution    文件:TabSurveyAudit.java   
private void loadListOmsetKategori() {
    listOmsetKategori.clear();
    omsetKategori = new TtDKunjunganSurveyorOmsetKatagori();
    omsetKategoriDao = new TtDKunjunganSurveyorOmsetKatagoriDao(getApplicationContext());
    omsetKategori.setKodeKunjungan(outlet.getKode()+new SimpleDateFormat("ddMMyyyy").format(new Date()));
    listOmsetKategori = omsetKategoriDao.listByExample(omsetKategori);
    adapterOmsetKategori = new OmsetKategoriAdapter(this, listOmsetKategori);
    lsOmset.setAdapter(adapterOmsetKategori);
    adapterOmsetKategori.notifyDataSetChanged();
    lsOmset.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
            omsetKategori = new TtDKunjunganSurveyorOmsetKatagori();
            omsetKategori = listOmsetKategori.get(index);
            omsetKategoriDao.delete(omsetKategori.getId());
            Toast.makeText(getApplicationContext(), "Omset Kategori Berhasil Dihapus", Toast.LENGTH_LONG).show();
            loadListPosm();
            return false;
        }
    });
}
项目:qsolution    文件:TabSurveyOutletActivity.java   
private void viewFasilitas() {
    fasilitasOutlet = new TmOutletFasilitas();
    fasilitasOutlet.setKodeOutlet(outlet.getKode());
    listFasilitasOutlet = new ArrayList<TmOutletFasilitas>();
    listFasilitasOutlet.clear();
    listFasilitasOutlet = fasilitasOutletDao.listByExample(fasilitasOutlet);
    fasilitasOutletAdapter= new FasilitasAdapter(TabSurveyOutletActivity.this, listFasilitasOutlet);
    viewFasilitas.setAdapter(fasilitasOutletAdapter);
    viewFasilitas.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int i, long index) {
                fasilitasOutlet = new TmOutletFasilitas();
                fasilitasOutlet = listFasilitasOutlet.get(i);
                fasilitasOutletDao.delete(fasilitasOutlet.getId());
                Toast.makeText(getApplicationContext(), "Fasilitas outlet berhasil dihapus", Toast.LENGTH_LONG).show();
                viewFasilitas();
            return false;
        }
    });
    fasilitasOutletAdapter.notifyDataSetChanged();

}
项目:qsolution    文件:TabSurveyOutlet.java   
private void loadListPosm() {
    posms.clear();
    outletPosm = new TtDKunjunganSurveyorOutletPosm();
    outletPosm.setKodeKunjungan(outlet.getKode()
            + kategori.getKodeKategori()
            + new SimpleDateFormat("ddMMyy").format(new Date()));
    posms = outletPosmDao.listByExample(outletPosm);
    adapter = new PosmOutletAdapter(this, posms);
    lsOutletPosm.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    lsOutletPosm.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int index, long arg3) {
            outletPosm = new TtDKunjunganSurveyorOutletPosm();
            outletPosm = posms.get(index);
            outletPosmDao.delete(outletPosm.getId());
            Toast.makeText(getApplicationContext(),
                    "Outlet posm berhasil dihapus", Toast.LENGTH_LONG)
                    .show();
            loadListPosm();
            return false;
        }
    });
}
项目:ics-openconnect    文件:LogFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.logwindow, container, false);

    mActivity = getActivity();

    mLogView = (ListView)v.findViewById(android.R.id.list);
    mLogView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                int position, long id) {
            ClipboardManager clipboard = (ClipboardManager)
                    mActivity.getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Log Entry",((TextView) view).getText());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(mActivity.getBaseContext(), R.string.copied_entry, Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    mSpeedView = (TextView)v.findViewById(R.id.speed);
    return v;
   }
项目:jukefox    文件:AlbumList.java   
private void registerEventListener() {
    list.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            eventListener.onListItemClicked(arg0, arg1, arg2);
        }
    });

    list.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int pos, long id) {
            return eventListener.onListItemLongClicked(parent, view, pos, id);
        }
    });
}
项目:jukefox    文件:DragManager.java   
public void registerArtistListViewDragging(final ListView listView,
        final ArtistListAdapter adapter) {
    // Drag and drop on long click.
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position,
                long id) {
            if (view == null) {
                return false;
            }
            startDraggingArtist(view, adapter.getItem(position));
            return true;
        }
    });
}
项目:jukefox    文件:DragManager.java   
public void registerAlbumViewDragging(final AdapterView<?> albumView,
        final ImageAlbumListAdapter adapter) {
    // Drag and drop on long click.
    albumView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position,
                long id) {
            // TODO: this shouldn't be null, but it becomes null from
            // this touch listener when we perform long click. investigate, also
            // the three time same code above.
            if (view == null) {
                return false;
            }
            startDraggingAlbum(view, adapter.getItem(position));
            return true;
        }
    });
}
项目:jukefox    文件:DragManager.java   
public void registerAlbumViewDragging(final AlbumAdapter adapter) {
    // Drag and drop on long click.
    adapter.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position,
                long id) {
            // TODO: this shouldn't be null, but it becomes null from
            // this touch listener when we perform long click. investigate, also
            // the three time same code above.
            if (view == null) {
                return false;
            }
            startDraggingAlbum(view, adapter.getItem(position));
            return true;
        }
    });
}
项目:triples    文件:BaseGameListFragment.java   
/** Called when the activity is first created. */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
  super.onActivityCreated(savedInstanceState);
  mApplication = Application.getInstance(getActivity());

  mAdapter = createArrayAdapter();
  setListAdapter(mAdapter);

  final Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);

  getListView()
      .setOnItemLongClickListener(
          new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(
                AdapterView<?> parent, View view, final int position, long id) {
              vibrator.vibrate(50);
              AlertDialog alert =
                  createDeleteAlertDialog((Game) parent.getItemAtPosition(position));
              alert.show();
              return true;
            }
          });
}
项目:CameraV    文件:UserManagementFragment.java   
private void initOrganizations()
{
    listOrganizations = informaCam.installedOrganizations.listOrganizations();

    organizationsHolder.setOnItemLongClickListener(new OnItemLongClickListener()
    {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int viewId, long l)
        {
            IOrganization org = listOrganizations.get((int) l);
            ((HomeActivityListener) a).getContextualMenuFor(org);

            return true;
        }
    });

    listOrganizationsAdapter = new OrganizationsListAdapter(listOrganizations);
    organizationsHolder.setAdapter(listOrganizationsAdapter);
}
项目:aws-sdk-android-samples    文件:UserListActivity.java   
protected void onPostExecute(Void result) {

            arrayAdapter = new ArrayAdapter<String>(UserListActivity.this,
                    R.layout.user_list_item, labels);
            setListAdapter(arrayAdapter);

            ListView lv = getListView();
            lv.setOnItemLongClickListener(new OnItemLongClickListener() {

                @Override
                public boolean onItemLongClick(AdapterView<?> av, View v,
                        int pos, long id) {
                    return onLongListItemClick(v, pos, id);
                }
            });

            Toast toast = Toast.makeText(UserListActivity.this,
                    "Tap and hold to delete users", Toast.LENGTH_LONG);
            toast.show();
        }
项目:WHUMap    文件:CaldroidFragment.java   
/**
 * Callback to listener when date is valid (not disable, not outside of
 * min/max date)
 * 
 * @return
 */
private OnItemLongClickListener getDateItemLongClickListener() {
    dateItemLongClickListener = new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                int position, long id) {

            DateTime dateTime = dateInMonthsList.get(position);

            if (caldroidListener != null) {
                if ((minDateTime != null && dateTime.lt(minDateTime))
                        || (maxDateTime != null && dateTime.gt(maxDateTime))
                        || (disableDates != null && disableDates
                                .indexOf(dateTime) != -1)) {
                    return false;
                }
                Date date = CalendarHelper.convertDateTimeToDate(dateTime);
                caldroidListener.onLongClickDate(date, view);
            }

            return true;
        }
    };

    return dateItemLongClickListener;
}
项目:CSipSimple    文件:CallLogListFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);


    // Modify list view
    ListView lv = getListView();
    lv.setVerticalFadingEdgeEnabled(true);
    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lv.setItemsCanFocus(false);
    } else {
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }

    // Map long press
    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> ad, View v, int pos, long id) {
            turnOnActionMode();
            getListView().setItemChecked(pos, true);
            mMode.invalidate();
            return true;
        }
    });
}
项目:XListView    文件:PullListView.java   
/**
 * 设置列表视图长按事件监听器
 * 
 * @param itemListener
 */
public void setOnItemLongClickListener(
        final OnListItemLongClickListener itemListener) {
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                int position, long id) {
            itemListener.onItemLongClick(parent, view, position, id);
            return true;
        }
    });
}
项目:AndroidBottomSheet    文件:BottomSheet.java   
/**
 * Creates and returns a listener, which allows to observe when the items of a bottom sheet have
 * been long-clicked.
 *
 * @return The listener, which has been created, as an instance of the type {qlink
 * OnItemLongClickListener}
 */
private OnItemLongClickListener createItemLongClickListener() {
    return new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, final View view,
                                       final int position, final long id) {

            if (!rootView.isDragging() && !rootView.isAnimationRunning() &&
                    itemLongClickListener != null) {
                int index = position;

                if (adapter.containsDividers()) {
                    for (int i = position; i >= 0; i--) {
                        if (adapter.getItem(i) == null ||
                                (adapter.getItem(i) instanceof Divider &&
                                        i % adapter.getColumnCount() > 0)) {
                            index--;
                        }
                    }
                }

                return itemLongClickListener
                        .onItemLongClick(parent, view, index, getId(position));
            }

            return false;
        }

    };
}
项目:AyoSunny    文件:DrawableScannerAndPicker.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.acitivty_drawable_picker);

    ListView lv_resources = (ListView) findViewById(R.id.lv_resources);
    TextView tv_pkg = (TextView) findViewById(R.id.tv_pkg);

    String pkgName = getIntent().getStringExtra("pkgName");//"com.example.views";
    String type = getIntent().getStringExtra("type");//"drawable";
    //String pkgName = "android";
    tv_pkg.setText(pkgName);
    resources = scanDrawableResources(pkgName, type);
    lv_resources.setAdapter(new ResourceAdapter());

    lv_resources.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            ResourceInfo r = resources.get(arg2);
            Intent intent = new Intent();
            intent.putExtra("name", r.name);
            intent.putExtra("id", r.id);
            setResult(200, intent);
            finish();
            return true;
        }
    });
}
项目:AyoSunny    文件:DrawableScannerAndPicker.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sp_ac_res_picker);

    ListView lv_resources = (ListView) findViewById(R.id.lv_resources);
    TextView tv_pkg = (TextView) findViewById(R.id.tv_pkg);

    String pkgName = getIntent().getExtra("pkgName");//"com.example.views";
    String type = getIntent().getExtra("type");//"drawable";
    //String pkgName = "android";
    tv_pkg.setText(pkgName);
    resources = scanDrawableResources(pkgName, type);
    lv_resources.setAdapter(new ResourceAdapter());

    lv_resources.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            ResourceInfo r = resources.get(arg2);
            if(hasResultCallback()){
                getResultCallback().onResult(r);
            }
            finish();
            return true;
        }
    });
}
项目:lr_dialer    文件:AbstractAQuery.java   
/**
 * Register a callback method for when an item is long clicked in the ListView.
 *
 * @param listener The callback method.
 * @return self
 */
public T itemLongClicked(OnItemLongClickListener listener)
{
    if (view instanceof AdapterView)
    {
        AdapterView<?> alv = (AdapterView<?>) view;
        alv.setOnItemLongClickListener(listener);
    }
    return self();
}
项目:AndroidAdapters    文件:AbstractExpandableListAdapterFragment.java   
/**
 * Creates and returns a listener, which allows to disable an item, when it is long-clicked.
 *
 * @return The listener, which has been created, as an instance of the type {@link
 * OnItemLongClickListener}
 */
private OnItemLongClickListener createItemLongClickListener() {
    return new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, final View view,
                                       final int position, final long id) {
            int groupIndex = ExpandableListView.getPackedPositionGroup(id);
            int childIndex = ExpandableListView.getPackedPositionChild(id);
            boolean enabled;

            if (childIndex != -1) {
                adapter.triggerChildEnableState(groupIndex, childIndex);
                enabled = adapter.isChildEnabled(groupIndex, childIndex);
            } else {
                adapter.triggerGroupEnableState(groupIndex);
                enabled = adapter.isGroupEnabled(groupIndex);
            }

            if (enabled) {
                Toast.makeText(getActivity(), R.string.enabled_item_toast, Toast.LENGTH_SHORT)
                        .show();
            } else {
                Toast.makeText(getActivity(), R.string.disabled_item_toast, Toast.LENGTH_SHORT)
                        .show();
            }

            return true;
        }
    };
}
项目:Bimoid-IM-Android    文件:DetailSearchActivity.java   
private void initViews(){
   if(ColorScheme.initialized) ((LinearLayout)findViewById(R.id.search_back)).setBackgroundColor(ColorScheme.getColor(29));
    if(ColorScheme.initialized) utilities.setLabel(((TextView)findViewById(R.id.detail_search_header)), "s_detail_search_header").setTextColor(ColorScheme.getColor(3));
    if(ColorScheme.initialized) ((LinearLayout)findViewById(R.id.detail_search_divider)).setBackgroundColor(ColorScheme.getColor(4));
    search_results = (ListView)findViewById(R.id.detail_search_result_list);
Interface.attachSelector(search_results);
    search_results.setAdapter(adapter);
    search_results.setOnItemLongClickListener(new OnItemLongClickListener(){
    @Override
    public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        context_item = adapter.getItem(arg2);
        removeDialog(3);
        showDialog(3);
        return false;
    }
    });
    set_criteries = (Button)findViewById(R.id.detail_search_set_criteries);
   if(ColorScheme.initialized) set_criteries.setTextColor(ColorScheme.getColor(24));
   Interface.attachButtonStyle(set_criteries);
    set_criteries.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v) {
        removeDialog(0);
        showDialog(0);
    }
    });
    set_criteries.setText(Locale.getString("s_set_detail_search_params"));
    begin_search = (Button)findViewById(R.id.detail_search_begin_search);
   if(ColorScheme.initialized) begin_search.setTextColor(ColorScheme.getColor(24));
   Interface.attachButtonStyle(begin_search);
   begin_search.setText(Locale.getString("s_do_search"));
   Interface.attachBackground((LinearLayout)findViewById(R.id.detail_search_header_field), Interface.search_top_panel);
   Interface.attachBackground((LinearLayout)findViewById(R.id.detail_search_results_field), Interface.search_list_back);
  }
项目:MIME    文件:PoseListHelper.java   
/**
 * Creates and initializes the ListView
 * @param ctx Application context
 * @param pr Instance of the PoseRecognizer
 * @param list ListView
 * @param onLongClickCallback Action that will be executed when an item is long clicked
 */
@SuppressLint("InflateParams")
public void init(final Context ctx, PoseRecognizer pr, ListView list, final Util.Callback<Integer> onLongClickCallback) {
    LayoutInflater li = LayoutInflater.from(ctx);
    View headerView = li.inflate(R.layout.list_header, null);
    list.addHeaderView(headerView);

    mAdapter = new PoseListAdapter(ctx, pr.getPoses());
    list.setAdapter(mAdapter);

    list.setOnItemLongClickListener(new OnItemLongClickListener() {
        // Long click listener for list items to delete single items from list
           public boolean onItemLongClick(AdapterView<?> parent, View strings, final int position, long id) {
            Util.vibrate(ctx, 150);
            // Show confirmation dialog; header view = position 0
            if (position >= 1) {
                Util.confirm(ctx, R.string.message_delete_pose, new Util.Callback<Void>(){
                    @Override
                    public void call(Void param) {
                        onLongClickCallback.call(position-1);
                        mAdapter.notifyDataSetChanged();
                    }
                });
            }
            return true;
           }
    });

    mListView = list;
}
项目:Conquer    文件:MyHistoryActivity.java   
/**
 * 初始化
 */
private void init() {
    lv_history = (ListView) findViewById(R.id.lv_history);
    cardList = new ArrayList<Card>();
    adapter = new MyHistoryAdapter(context, cardList);
    lv_history.setAdapter(adapter);
    lv_history.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
            AlertDialogUtils.show(context, "删除记录", "确认删除吗?", "确定", "取消", new OkCallBack() {
                public void onOkClick(DialogInterface dialog, int which) {
                    TaskUtil.deleteMyCard(context, cardList.get(position).getObjectId(), new DeleteCardistener() {
                        @Override
                        public void onSuccess() {
                            cardList.remove(position);
                            adapter.notifyDataSetChanged();
                        }

                        @Override
                        public void onError(int errorCord, String msg) {
                        }
                    });
                }
            }, null);

            return false;
        }
    });
    getDate();
}
项目:IOT-Espressif-Android    文件:EspMainFragment.java   
public GroupHolder(View itemView) {
    super(itemView);

    view = itemView;
    text = (TextView)itemView.findViewById(R.id.group_text);

    itemView.setOnClickListener(new OnItemClickListener());
    itemView.setOnLongClickListener(new OnItemLongClickListener());
}
项目:Fabric-Example-App-Android    文件:MoPubAdAdapterTest.java   
@Test
public void setOnItemLongClickListener_withAdPosition_shouldNotCallListener() {
    subject.setOnItemLongClickListener(mockListView, mockOnItemLongClickListener);

    ArgumentCaptor<OnItemLongClickListener> listenerCaptor =
            ArgumentCaptor.forClass(OnItemLongClickListener.class);
    verify(mockListView).setOnItemLongClickListener(listenerCaptor.capture());

    OnItemLongClickListener listener = listenerCaptor.getValue();
    listener.onItemLongClick(mockListView, mockItemView, AD_POSITION, 0);

    verify(mockOnItemLongClickListener, never()).onItemLongClick(
            any(AdapterView.class), any(View.class), anyInt(), anyInt());
}
项目:Fabric-Example-App-Android    文件:MoPubAdAdapterTest.java   
@Test
public void setOnItemLongClickListener_withNonAdPosition_shouldCallListener() {
    subject.setOnItemLongClickListener(mockListView, mockOnItemLongClickListener);

    ArgumentCaptor<OnItemLongClickListener> listenerCaptor =
            ArgumentCaptor.forClass(OnItemLongClickListener.class);
    verify(mockListView).setOnItemLongClickListener(listenerCaptor.capture());

    OnItemLongClickListener listener = listenerCaptor.getValue();
    listener.onItemLongClick(mockListView, mockItemView, AD_POSITION + 1, 0);

    verify(mockOnItemLongClickListener).onItemLongClick(
            mockListView, mockItemView, AD_POSITION, 0);
}
项目:Viz    文件:Favorites.java   
@Override
public void onActivityCreated(Bundle savedState) {
    super.onActivityCreated(savedState);

    Log.d();

    getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                int position, long id) {
            getActivity().startActionMode(new FavoritesActionMode(position, id));
            return true;
        }
    });
}
项目:NGA-CLIENT-VER-OPEN-SOURCE    文件:NonameArticleListFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    listview = new ListView(this.getActivity());

    listview.setBackgroundResource(ThemeManager.getInstance()
            .getBackgroundColor());
    listview.setDivider(null);

    activeActionMode();
    listview.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listview.setOnItemLongClickListener(new OnItemLongClickListener() {

        @TargetApi(11)
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view,
                                       int position, long id) {
            ListView lv = (ListView) parent;
            lv.setItemChecked(position, true);
            if (mActionModeCallback != null) {
                ((AppCompatActivity) getActivity())
                        .startSupportActionMode((Callback) mActionModeCallback);
                return true;
            }
            return false;
        }

    });

    listview.setDescendantFocusability(ListView.FOCUS_AFTER_DESCENDANTS);

    return listview;
}