android.widget.GridView.setOnItemLongClickListener()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中android.widget.GridView.setOnItemLongClickListener()方法的一些代码示例,展示了GridView.setOnItemLongClickListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.setOnItemLongClickListener()方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:setOnItemLongClickListener

GridView.setOnItemLongClickListener介绍

暂无

代码示例

代码示例来源:origin: TonicArtos/StickyGridHeaders

@Override
public void setOnItemLongClickListener(
    android.widget.AdapterView.OnItemLongClickListener listener) {
  this.mOnItemLongClickListener = listener;
  super.setOnItemLongClickListener(this);
}

代码示例来源:origin: TommyLemon/Android-ZBLibrary

@Override
public void initEvent() {//必须在onCreate方法内调用
  super.initEvent();
  //如果adapter类型是zuo.biao.library.base.BaseAdapter,这两句就不用写了
  lvBaseList.setOnItemClickListener(this);
  lvBaseList.setOnItemLongClickListener(this);
}

代码示例来源:origin: liaohuqiu/android-GridViewWithHeaderAndFooter

@Override
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
  mOnItemLongClickListener = listener;
  super.setOnItemLongClickListener(getItemClickHandler());
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
protected void layoutInit(LayoutInflater inflater, Bundle savedInstanceSate) {
  super.layoutInit(inflater, savedInstanceSate);
  
  getRefreshView().setOnItemClickListener(this);
  getRefreshView().setOnItemLongClickListener(this);
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
  setCancelable(true);
  
  View view = View.inflate(getActivity(), R.layout.ui_mdcolors_dialog, null);
  
  GridView gridView = (GridView) view.findViewById(R.id.grid);
  gridView.setAdapter(new MDColorsAdapter());
  gridView.setOnItemClickListener(this);
  gridView.setOnItemLongClickListener(this);
  
  return new MaterialDialog.Builder(getActivity())
                    .customView(view, false)
                    .positiveText(R.string.cancel)
                    .build();
}

代码示例来源:origin: daimajia/AndroidSwipeLayout

gridView.setAdapter(adapter);
gridView.setSelected(false);
gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
  @Override
  public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

代码示例来源:origin: bingoogolapple/BGARefreshLayout-Android

@Override
protected void setListener() {
  mRefreshLayout.setDelegate(this);
  mRefreshLayout.setRefreshScaleDelegate(new BGARefreshLayout.BGARefreshScaleDelegate() {
    @Override
    public void onRefreshScaleChanged(float scale, int moveYDistance) {
      Log.i(TAG, "scale:" + scale + " moveYDistance:" + moveYDistance);
    }
  });
  mDataGv.setOnItemClickListener(this);
  mDataGv.setOnItemLongClickListener(this);
  mDataGv.setOnScrollListener(new AbsListView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
      Log.i(TAG, "滚动状态变化");
    }
    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
      Log.i(TAG, "正在滚动");
    }
  });
  mAdapter = new NormalAdapterViewAdapter(mApp);
  mAdapter.setOnItemChildClickListener(this);
  mAdapter.setOnItemChildLongClickListener(this);
  getViewById(R.id.beginRefreshing).setOnClickListener(this);
  getViewById(R.id.beginLoadingMore).setOnClickListener(this);
}

代码示例来源:origin: UweTrottmann/SeriesGuide

@Override
public void setOnItemLongClickListener(
    android.widget.AdapterView.OnItemLongClickListener listener) {
  this.mOnItemLongClickListener = listener;
  super.setOnItemLongClickListener(this);
}

代码示例来源:origin: canqihe/TmallSale

@Override
public void setOnItemLongClickListener(
    OnItemLongClickListener listener) {
  this.mOnItemLongClickListener = listener;
  super.setOnItemLongClickListener(this);
}

代码示例来源:origin: zzkong/BaseProject

@Override
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
  mOnItemLongClickListener = listener;
  super.setOnItemLongClickListener(getItemClickHandler());
}

代码示例来源:origin: madreain/AndroidDream

@Override
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
  mOnItemLongClickListener = listener;
  super.setOnItemLongClickListener(getItemClickHandler());
}

代码示例来源:origin: navyifanr/AndroidTrainingDemo

@Override
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
  mOnItemLongClickListener = listener;
  super.setOnItemLongClickListener(getItemClickHandler());
}

代码示例来源:origin: AlexMofer/ProjectX

private void initView() {
  HeaderFooterListener listener = new HeaderFooterListener();
  super.setOnItemClickListener(listener);
  super.setOnItemLongClickListener(listener);
  super.setOnItemSelectedListener(listener);
}

代码示例来源:origin: qq8585083/DragIcon

private void initView() {
  HeaderFooterListener listener = new HeaderFooterListener();
  super.setOnItemClickListener(listener);
  super.setOnItemLongClickListener(listener);
  super.setOnItemSelectedListener(listener);
}

代码示例来源:origin: TeamFatCat/Easy_Transfer

@Override
public void initListener() {
  super.initListener();
  mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
      Intent intent = new Intent();
      //用intent.putExtra(String name, String value);来传递参数。
      intent.putExtra("PicturePath", mImgList.get(position).getPath());
      intent.setClass(getContext(), PictureActivity.class);
      startActivity(intent);
    }
  });
  mGridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
    @Override
    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
      ArrayList<String> fileList = new ArrayList<String>();
      for (int i = 0; i < PictureUtils.pictureSelect.size(); i++) {
        if (PictureUtils.pictureSelect.get(i + "").equals(PictureUtils.MEDIA_CHECKED)) {
          fileList.add(mImgList.get(i).getPath());
        }
      }
      mSendFile.sendFileList(fileList);   //发送文件
      return true;
    }
  });
}

代码示例来源:origin: powerpoint45/BasicLauncher

@Override
protected void onPostExecute(String result){
  if (drawerAdapterObject == null){
    drawerAdapterObject = new DrawerAdapter(activity, pacs);
    drawerGrid.setAdapter(drawerAdapterObject);
    drawerGrid.setOnItemClickListener(new DrawerClickListener(activity, pacs, pm));
    drawerGrid.setOnItemLongClickListener(new DrawerLongClickListener(activity, slidingDrawer, homeView,pacs));
  }else{
    drawerAdapterObject.pacsForAdapter = pacs;
    drawerAdapterObject.notifyDataSetInvalidated();
  }
}

代码示例来源:origin: ApolloAuto/apollo-DuerOS

@Override
  public void handleMessage(Message msg) {
    super.handleMessage(msg);
    activity = weakReference.get();
    if (activity == null) {
      return;
    }
    switch (msg.what) {
      case GET_ALL_APP:
        activity.mAppAdapter = new AppManagerAdapter(activity.mContext,
            activity.mAllAppList);
        activity.mAllAppGridView.setAdapter(activity.mAppAdapter);
        activity.mAllAppGridView.setOnItemClickListener(activity);
        activity.mAllAppGridView.setOnItemLongClickListener(activity);
        break;
      case UPDATE_ALL_APP:
        activity.mAppAdapter.setAppInfos(activity.mAllAppList);
        activity.mAppAdapter.notifyDataSetChanged();
        break;
      default:
    }
  }
}

代码示例来源:origin: freedom10086/Ruisi

WaterHolder(View itemView) {
    super(itemView);
    GridView g = (GridView) itemView;
    int p12 = DimenUtils.dip2px(context, 12);
    g.setVerticalSpacing(p12);
    g.setHorizontalSpacing(p12);
    WindowManager wm = (WindowManager) context
        .getSystemService(Context.WINDOW_SERVICE);
    Point point = new Point();
    wm.getDefaultDisplay().getSize(point);
    int width = point.x;
    int itemWidth = (width - (p12 * 9)) / 8;
    g.setLayoutParams(new ViewGroup.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT,
        (ds.size() <= 8 ? itemWidth + p12 * 2 : itemWidth * 2 + p12 * 3)));
    g.setPadding(p12, p12, p12, p12);
    g.setNumColumns(8);
    g.setAdapter(new WaterBAdapter(itemWidth));
    g.setOnItemClickListener((parent, view, position, id) -> {
      WaterData d = ds.get(position);
      UserDetailActivity.open(context, d.name, d.imgSrc, d.uid);
    });
    g.setOnItemLongClickListener((parent, view, position, id) -> {
      WaterData d = ds.get(position);
      Toast.makeText(context, d.name + "\n帖子数:" + d.num, Toast.LENGTH_SHORT).show();
      return true;
    });
  }
}

代码示例来源:origin: powerpoint45/BasicLauncher

public void set_pacs(boolean init){
  Intent mainIntent = new Intent(Intent.ACTION_MAIN,null);
  mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  List<ResolveInfo> pacsList = pm.queryIntentActivities(mainIntent, 0);
  pacs = new Pac[pacsList.size()];
  for(int I=0;I<pacsList.size();I++){
    pacs[I]= new Pac();
    pacs[I].icon=pacsList.get(I).loadIcon(pm);
    pacs[I].packageName=pacsList.get(I).activityInfo.packageName;
    pacs[I].name=pacsList.get(I).activityInfo.name;
    pacs[I].label=pacsList.get(I).loadLabel(pm).toString();
  }
  new SortApps().exchange_sort(pacs);
  themePacs();
  
  if (init){
    drawerAdapterObject = new DrawerAdapter(this, pacs);
    drawerGrid.setAdapter(drawerAdapterObject);
    drawerGrid.setOnItemClickListener(new DrawerClickListener(this, pacs, pm));
    drawerGrid.setOnItemLongClickListener(new DrawerLongClickListener(this, slidingDrawer, homeView,pacs));
  }else{
    drawerAdapterObject.pacsForAdapter = pacs;
    drawerAdapterObject.notifyDataSetInvalidated();
  }
}

代码示例来源:origin: michael-rapp/AndroidBottomSheet

/**
 * Shows the grid view, which is used to show the bottom sheet's items.
 */
private void showGridView() {
  gridView = contentContainer.findViewById(R.id.bottom_sheet_grid_view);
  if (gridView != null) {
    contentContainer.setVisibility(View.VISIBLE);
    if (getStyle() == Style.GRID) {
      int horizontalPadding = getContext().getResources()
          .getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_horizontal_padding);
      int paddingBottom = getContext().getResources()
          .getDimensionPixelSize(R.dimen.bottom_sheet_grid_padding_bottom);
      gridView.setPadding(horizontalPadding, 0, horizontalPadding, paddingBottom);
      gridView.setNumColumns(GridView.AUTO_FIT);
      gridView.setColumnWidth(getContext().getResources()
          .getDimensionPixelSize(R.dimen.bottom_sheet_grid_item_size));
    } else {
      int paddingBottom = getContext().getResources()
          .getDimensionPixelSize(R.dimen.bottom_sheet_list_padding_bottom);
      gridView.setPadding(0, 0, 0, paddingBottom);
      gridView.setNumColumns(getStyle() == Style.LIST_COLUMNS &&
          (getDeviceType(getContext()) == DisplayUtil.DeviceType.TABLET ||
              getOrientation(getContext()) == DisplayUtil.Orientation.LANDSCAPE) ?
          2 : 1);
    }
    gridView.setOnItemClickListener(createItemClickListener());
    gridView.setOnItemLongClickListener(createItemLongClickListener());
    gridView.setAdapter(adapter);
  }
}

相关文章

GridView类方法