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

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

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

GridView.setSelector介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public class SmileCustomDialog extends Dialog {
Context mcontext;
GridView mGridview;

public GridView getGridview() {
  return mGridview;
}

public SmileCustomDialog(final Context context) {
  super(context, R.style.SlideFromBottomDialog);
  this.mcontext = context;
  LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View v = inflater.inflate(R.layout.emocategorydialog, null);
  mGridview = (GridView) v.findViewById(R.id.emogrid);
  mGridview.setSelector(new ColorDrawable(Color.TRANSPARENT));

  ImageAdapter mAdapter = new ImageAdapter(mcontext);
  mGridview.setAdapter(mAdapter);
  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  this.setContentView(v);

  WindowManager.LayoutParams params = this.getWindow().getAttributes();
  this.setCanceledOnTouchOutside(true);
  params.y = -100;
  this.getWindow().setAttributes(params);

}

}

代码示例来源:origin: bilibili/BiliShare

protected static GridView createShareGridView(final Context context, AdapterView.OnItemClickListener onItemClickListener) {
  GridView grid = new GridView(context);
  ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) {
    // no need scroll
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.bili_socialize_shareboard_item, parent, false);
      view.setBackgroundDrawable(null);
      ImageView image = (ImageView) view.findViewById(R.id.bili_socialize_shareboard_image);
      TextView platform = (TextView) view.findViewById(R.id.bili_socialize_shareboard_pltform_name);
      ShareTarget target = getItem(position);
      image.setImageResource(target.iconId);
      platform.setText(target.titleId);
      return view;
    }
  };
  grid.setNumColumns(-1);
  grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
  grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.bili_socialize_shareboard_size));
  grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
  grid.setSelector(R.drawable.bili_socialize_selector_item_background);
  grid.setAdapter(adapter);
  grid.setOnItemClickListener(onItemClickListener);
  return grid;
}

代码示例来源:origin: dabutaizha/juzimi

protected static GridView createShareGridView(final Context context, AdapterView.OnItemClickListener onItemClickListener) {
  GridView grid = new GridView(context);
  ListAdapter adapter = new ArrayAdapter<ShareTarget>(context, 0, shareTargets) {
    // no need scroll
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.shareboard_item, parent, false);
      view.setBackgroundDrawable(null);
      ImageView image = view.findViewById(R.id.shareboard_image);
      TextView platform = view.findViewById(R.id.shareboard_pltform);
      ShareTarget target = getItem(position);
      image.setImageResource(target.iconId);
      platform.setText(target.titleId);
      return view;
    }
  };
  grid.setNumColumns(3);
  grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
  grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.shareboard_size));
  grid.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
  grid.setSelector(R.drawable.background_shareboard);
  grid.setAdapter(adapter);
  grid.setOnItemClickListener(onItemClickListener);
  return grid;
}

代码示例来源:origin: ckj375/Android-Sticker

gv.setSelector(new ColorDrawable(Color.TRANSPARENT));
adapter = new MaterialAdapter(this,materialList);
gv.setAdapter(adapter);

代码示例来源:origin: googlecodelabs/android-topeka

@Override
protected View createQuizContentView() {
  mAnswerView = new GridView(getContext());
  mAnswerView.setSelector(R.drawable.selector_button);
  mAnswerView.setNumColumns(2);
  mAnswerView.setAdapter(new OptionsQuizAdapter(getQuiz().getOptions(),
      R.layout.item_answer));
  mAnswerView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
      allowAnswer();
      mAnswered = position;
    }
  });
  return mAnswerView;
}

代码示例来源:origin: werbhelius/Werb

/**
 * 创建显示表情的GridView
 */
private GridView createEmotionGridView(List<String> emotionNames, int gvWidth, int padding, int itemWidth, int gvHeight) {
  // 创建GridView
  GridView gv = new GridView(context);
  gv.setBackgroundResource(R.color.bg_gray);
  gv.setSelector(R.color.transparent);
  gv.setNumColumns(7);
  gv.setPadding(padding, padding, padding, padding);
  gv.setHorizontalSpacing(padding);
  gv.setVerticalSpacing(padding);
  ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(gvWidth, gvHeight);
  gv.setLayoutParams(params);
  // 给GridView设置表情图片
  EmotionGvAdapter adapter = new EmotionGvAdapter(context, emotionNames, itemWidth);
  gv.setAdapter(adapter);
  gv.setOnItemClickListener(this);
  return gv;
}

代码示例来源:origin: nomanr/WeekCalendar

private GridView getDaysNames() {
  daysName = new GridView(getContext());
  daysName.setSelector(new StateListDrawable());
  daysName.setNumColumns(7);

代码示例来源:origin: Meiqia/MeiqiaSDK-Android

gridView.setHorizontalScrollBarEnabled(false);
gridView.setHorizontalFadingEdgeEnabled(false);
gridView.setSelector(android.R.color.transparent);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  @Override

代码示例来源:origin: TongmingWu/Manga

gvChapter.setSelector(new ColorDrawable(Color.TRANSPARENT));
gvChapter.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  @Override

代码示例来源:origin: shinezejian/emotionkeyboard

/**
 * 创建显示表情的GridView
 */
private GridView createEmotionGridView(List<String> emotionNames, int gvWidth, int padding, int itemWidth, int gvHeight) {
  // 创建GridView
  GridView gv = new GridView(getActivity());
  //设置点击背景透明
  gv.setSelector(android.R.color.transparent);
  //设置7列
  gv.setNumColumns(7);
  gv.setPadding(padding, padding, padding, padding);
  gv.setHorizontalSpacing(padding);
  gv.setVerticalSpacing(padding * 2);
  //设置GridView的宽高
  ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(gvWidth, gvHeight);
  gv.setLayoutParams(params);
  // 给GridView设置表情图片
  EmotionGridViewAdapter adapter = new EmotionGridViewAdapter(getActivity(), emotionNames, itemWidth,emotion_map_type);
  gv.setAdapter(adapter);
  //设置全局点击事件
  gv.setOnItemClickListener(GlobalOnItemClickManagerUtils.getInstance(getActivity()).getOnItemClickListener(emotion_map_type));
  return gv;
}

代码示例来源:origin: chsmy/CitySelector

gvAdapter = new MyGridViewAdapter(this,mReMenCitys);
mGridView.setAdapter(gvAdapter);
mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT));

代码示例来源:origin: chengzichen/KrGallery

listView.setVerticalSpacing(AndroidUtilities.dp(4));
listView.setHorizontalSpacing(AndroidUtilities.dp(4));
listView.setSelector(R.drawable.list_selector);
frameLayout.addView(listView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView

相关文章

GridView类方法