Java 类android.widget.GridView 实例源码

项目:OSchina_resources_android    文件:EmojiPageFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    sGrid = new GridView(getActivity());
    sGrid.setNumColumns(KJEmojiConfig.COLUMNS);
    adapter = new EmojiGridAdapter(getActivity(), datas);
    sGrid.setAdapter(adapter);
    sGrid.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                                int position, long id) {
            EditText editText = (EditText) getActivity().findViewById(
                    R.id.emoji_titile_input);
            if (listener != null) {
                listener.onEmojiClick((Emojicon) parent.getAdapter()
                        .getItem(position));
            }
            if (editText != null)
                InputHelper.input2OSC(editText, (Emojicon) parent.getAdapter()
                        .getItem(position));
        }
    });
    sGrid.setSelector(R.drawable.ic_material);
    return sGrid;
}
项目:EmotionApp    文件:EmotionComplateFragment.java   
/**
 * 创建显示表情的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().getOnItemClickListener(getActivity(),emotion_map_type));
    return gv;
}
项目:PictureShow    文件:TimeLinePage.java   
private void initView() {
    gridView = (GridView) rootView.findViewById(R.id.grid);
    bottomView = rootView.findViewById(R.id.bottom_layout);
    gridAdapter = new TimeLineAdapter(getActivity());
    gridAdapter.setDecodeSize(decodeBitmapWidth);
    gridView.setAdapter(gridAdapter);
    gridAdapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            super.onChanged();
        }

        @Override
        public void onInvalidated() {
            super.onInvalidated();
        }

    });

    gridView.setOnItemClickListener(this);
    gridView.setOnItemLongClickListener(this);
}
项目:RestaurantApp    文件:CategoryFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_category, container, false);

    categoryList = new ArrayList<>();

    Request request = new Request(getActivity(), urlCategory, com.android.volley.Request.Method.GET);
    request.requestVolley(this);
    progressDialog = new ProgressDialog(getActivity());
    progressDialog.setMessage("Menü Yükleniyor.");
    progressDialog.show();

    gridView = (GridView) view.findViewById(R.id.gvCat);
    gridView.setOnItemClickListener(this);

    return view;
}
项目:androidadvanced    文件:GridViewExampleActivity.java   
@Override
public void onResume() {
    super.onResume();

    // Load from file "cities.json" first time
    if (mAdapter == null) {
        List<City> cities = loadCities();

        //This is the GridView adapter
        mAdapter = new CityAdapter(this);
        mAdapter.setData(cities);

        //This is the GridView which will display the list of cities
        mGridView = (GridView) findViewById(R.id.cities_list);
        mGridView.setAdapter(mAdapter);
        mGridView.setOnItemClickListener(GridViewExampleActivity.this);
        mAdapter.notifyDataSetChanged();
        mGridView.invalidate();
    }
}
项目:EditorImageAndText    文件:ImageGridActivity.java   
protected void initView() {
    gridView = (GridView) findViewById(R.id.gridview);
    photo_delete = (ImageView) findViewById(R.id.photo_delete);
    photo_choose = (ImageView) findViewById(R.id.photo_choose);
    gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
    if (type == VIDEOTYPE) {
        adapter = new ImageGridAdapter(ImageGridActivity.this, null, videoList,
                mHandler, type);
    } else {
        adapter = new ImageGridAdapter(ImageGridActivity.this, dataList, null,
                mHandler, type);
    }
    dialog = new Dialog(this);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setTitle("数据上传");
    View view = View.inflate(this, R.layout.customerdialogcheckroll, null);
    bar = (ProgressBar) view.findViewById(R.id.customerdialog_pb);
    tip = (TextView) view.findViewById(R.id.customerdialog_tv);

    dialog.setContentView(view);
    gridView.setAdapter(adapter);
}
项目:GitHub    文件:SwipeRefreshMultipleViewsFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_sample, container, false);

    mSwipeRefreshLayout = (MultiSwipeRefreshLayout) view.findViewById(R.id.swiperefresh);

    // BEGIN_INCLUDE (change_colors)
    // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids
    mSwipeRefreshLayout.setColorSchemeResources(
            R.color.swipe_color_1, R.color.swipe_color_2,
            R.color.swipe_color_3, R.color.swipe_color_4);
    // END_INCLUDE (change_colors)

    mGridView = (GridView) view.findViewById(android.R.id.list);
    mEmptyView = view.findViewById(android.R.id.empty);
    return view;
}
项目:GitHub    文件:ColorChooserDialog.java   
@SuppressLint("DefaultLocale")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = new CircleView(getContext());
        convertView.setLayoutParams(new GridView.LayoutParams(circleSize, circleSize));
    }
    CircleView child = (CircleView) convertView;
    @ColorInt
    final int color = isInSub() ? mColorsSub[topIndex()][position] : mColorsTop[position];
    child.setBackgroundColor(color);
    if (isInSub())
        child.setSelected(subIndex() == position);
    else child.setSelected(topIndex() == position);
    child.setTag(String.format("%d:%d", position, color));
    child.setOnClickListener(ColorChooserDialog.this);
    child.setOnLongClickListener(ColorChooserDialog.this);
    return convertView;
}
项目:GitHub    文件:ImageGridFragment.java   
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View v = inflater.inflate(R.layout.image_grid_fragment, container, false);
    final GridView mGridView = (GridView) v.findViewById(R.id.gridView);
    mGridView.setAdapter(mAdapter);
    mGridView.setOnItemClickListener(this);
    mGridView.getViewTreeObserver().addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
                @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
                @Override
                public void onGlobalLayout() {
                    if (mAdapter.getNumColumns() == 0) {
                        final int numColumns = (int) Math.floor(
                                mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
                        if (numColumns > 0) {
                            final int columnWidth =
                                    (mGridView.getWidth() / numColumns) - mImageThumbSpacing;
                            mAdapter.setNumColumns(numColumns);
                            mAdapter.setItemHeight(columnWidth);

                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                                mGridView.getViewTreeObserver()
                                        .removeOnGlobalLayoutListener(this);
                            } else {
                                mGridView.getViewTreeObserver()
                                        .removeGlobalOnLayoutListener(this);
                            }
                        }
                    }
                }
            });

    return v;
}
项目:School1-Android    文件:TimetableFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    GridView view = (GridView) inflater.inflate(R.layout.fragment_timetable, container, false);

    /*if (savedInstanceState != null) {
        long[] ids = savedInstanceState.getLongArray("ids");
        String[] names = savedInstanceState.getStringArray("names");
        byte[] times = savedInstanceState.getByteArray("times");

        if (ids != null && names != null && times != null) {
            changes.clear();
            for (int i = 0; i < ids.length; i++)
                changes.add(new Lesson(ids[i], names[i], times[i], Codes.private_));
        }
    }
    view.setAdapter(new TimetableConfigAdapter(-1, changes));*/
    return view;
}
项目:stynico    文件:LotteryAPIActivity.java   
protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_lottery);
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
       etPeriod = forceCast(findViewById(R.id.etPeriod));
       tvDateTime = forceCast(findViewById(R.id.tvDateTime));
       tvName = forceCast(findViewById(R.id.tvName));
       tvSales = forceCast(findViewById(R.id.tvSales));
       tvPool = forceCast(findViewById(R.id.tvPool));
       tvPeriod = forceCast(findViewById(R.id.tvPeriod));
       tvLotteryNumber = forceCast(findViewById(R.id.tvLotteryNumber));

       GridView gvLotteryList = forceCast(findViewById(R.id.gvLotteryList));
       ListView lvLotteryResult = forceCast(findViewById(R.id.lvLotteryAward));
       gvLotteryList.setOnItemClickListener(this);

       //init data
       updateLotteryInfo(null, null, null, null, null, null);

       lotteryTypeList = new ArrayList<HashMap<String, Object>>();
       lotteryTypeListAdapter = new SimpleAdapter(this, lotteryTypeList, android.R.layout.simple_list_item_1, new String[]{"name"}, new int[]{android.R.id.text1});
       gvLotteryList.setAdapter(lotteryTypeListAdapter);

       lotteryResultList = new ArrayList<HashMap<String, Object>>();
       lotteryResultAdapter = new LotteryResultAdapter(this, lotteryResultList);
       lvLotteryResult.setAdapter(lotteryResultAdapter);

       //获取彩种列表
       ((Lottery) forceCast(MobAPI.getAPI(Lottery.NAME))).queryLotteryList(LotteryAPIActivity.this);
   }
项目:Phoenix-for-VK    文件:EmojiconGridView.java   
public EmojiconGridView(Context context, Emojicon[] emojicons, EmojiconsPopup emojiconPopup) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    mEmojiconPopup = emojiconPopup;
    rootView = inflater.inflate(R.layout.emojicon_grid, null);
    GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView);
    if (emojicons == null) {
        mData = People.DATA;
    } else {
        mData = Arrays.asList(emojicons).toArray(new Emojicon[emojicons.length]);
    }
    EmojiAdapter mAdapter = new EmojiAdapter(rootView.getContext(), mData);
    mAdapter.setEmojiClickListener(emojicon -> {
        if (mEmojiconPopup.getOnEmojiconClickedListener() != null) {
            mEmojiconPopup.getOnEmojiconClickedListener().onEmojiconClicked(emojicon);
        }
    });
    gridView.setAdapter(mAdapter);
}
项目:airgram    文件:EmojiView.java   
public void invalidateViews() {
    for (GridView gridView : views) {
        if (gridView != null) {
            gridView.invalidateViews();
        }
    }
}
项目:HiBangClient    文件:EmoteInputView.java   
public void init() {
inflate(getContext(), R.layout.common_emotionbar, this);
mGvDisplay = (GridView) findViewById(R.id.emotionbar_gv_display);
mRgInner = (RadioGroup) findViewById(R.id.emotionbar_rg_inner);
mIvDelete = (ImageView) findViewById(R.id.emotionbar_iv_delete);

mGvDisplay.setOnItemClickListener(this);
mRgInner.setOnCheckedChangeListener(this);
mIvDelete.setOnClickListener(this);

mDefaultAdapter = new EmoteAdapter(getContext(),
        BaseApplication.mEmoticons_Zem);
mEmojiAdapter = new EmoteAdapter(getContext(),
        BaseApplication.mEmoticons_Zemoji);
mGvDisplay.setAdapter(mDefaultAdapter);
mIsSelectedDefault = true;
}
项目:FireFiles    文件:DirectoryFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();
       final Resources res = context.getResources();
    final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

    mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    mListView.setMultiChoiceModeListener(mMultiListener);
    mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setOnItemClickListener(mItemListener);
    mGridView.setMultiChoiceModeListener(mMultiListener);
    mGridView.setRecyclerListener(mRecycleListener);

    return view;
}
项目:EmoticonGIFKeyboard    文件:EmoticonGridFragment.java   
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ViewFlipper mainViewFlipper = view.findViewById(R.id.recent_emoticon_flipper);

    List<Emoticon> emoticonList = getEmoticonsList(getArguments().getInt(ARG_CATEGORY_ID, -1));

    if (emoticonList.isEmpty()) {
        mainViewFlipper.setDisplayedChild(1);
    } else {
        mainViewFlipper.setDisplayedChild(0);

        GridView emoticonGrid = view.findViewById(R.id.emoticon_list_grid);
        emoticonGrid.setNumColumns(getResources().getInteger(R.integer.emoticon_recycler_view_span_size));
        emoticonGrid.setOnItemClickListener(this);

        //Bind the adapter
        //noinspection WrongConstant
        EmoticonGridAdapter emoticonGridAdapter = new EmoticonGridAdapter(getActivity(),
                mEmoticonProvider, emoticonList);
        emoticonGrid.setAdapter(emoticonGridAdapter);
    }
}
项目:AndroidDigIn    文件:ColorMatrixActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_color_matrix);
    gv = (GridView) findViewById(R.id.gv);
    findViewById(R.id.btn_reset).setOnClickListener(this);
    findViewById(R.id.btn_change).setOnClickListener(this);

    findViewById(R.id.btn_gray).setOnClickListener(this);
    findViewById(R.id.btn_gray2).setOnClickListener(this);
    findViewById(R.id.btn_invert).setOnClickListener(this);
    findViewById(R.id.btn_invert2).setOnClickListener(this);
    findViewById(R.id.btn_memo).setOnClickListener(this);
    findViewById(R.id.btn_desaturate).setOnClickListener(this);
    findViewById(R.id.btn_high_sat).setOnClickListener(this);

    cmv = (ColorMatrixView) findViewById(R.id.cmv);
    initEts();
    gv.setAdapter(new MyAdapter());
    resetColors();
}
项目:InstagramManager-Android    文件:DetailActivity.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final int pos = position;
    final Context context = parent.getContext();
    SquareImageView imageView;
    if (convertView == null) {
        // if it's not recycled, initialize some attributes
        imageView = new SquareImageView(context);
        imageView.setLayoutParams(new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(0, 0,0, 0);
    } else {
        imageView = (SquareImageView) convertView;
    }

    imageView.setImageResource(R.drawable.test);
    return imageView;

}
项目:Huochexing12306    文件:EditImageAty.java   
private void initViews() {
    GridView gvIcons = (GridView) findViewById(R.id.icons);
    SimpleAdapter adapter = new SimpleAdapter(this, getIcons(),
            R.layout.item_editimage, new String[] { "item", "resId" },
            new int[] { R.id.item_editimage_ivIcon,
                    R.id.item_editimaeg_tvResId });
    gvIcons.setAdapter(adapter);
    gvIcons.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            TextView tv1 = (TextView) arg1
                    .findViewById(R.id.item_editimaeg_tvResId);
            int resId = Integer.valueOf(tv1.getText().toString());
            Intent intent = new Intent();
            intent.putExtra(RESULT, resId);
            EditImageAty.this.setResult(EditImageAty.this.getIntent()
                    .getIntExtra(C_RESULT_CODE, 0), intent);
            EditImageAty.this.finish();
        }
    });
}
项目:xlight_android_native    文件:ScenarioMainFragment.java   
@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_main_scenario, container, false);

        iv_menu = (ImageView) view.findViewById(R.id.iv_menu);
        iv_menu.setOnClickListener(this);
        textTitle = (TextView) view.findViewById(R.id.tvTitle);
        textTitle.setText(R.string.scene);
        btn_add = (Button) view.findViewById(R.id.btn_add);
        btn_add.setVisibility(View.VISIBLE);
//        btn_add.setBackground(getActivity().getDrawable(R.drawable.control_add));
        btn_add.setBackgroundResource(R.drawable.control_add);
        btn_add.setOnClickListener(this);

        //setup recycler view
        gvCustom = (GridView) view.findViewById(R.id.gvCustom);
        gvSystem = (GridView) view.findViewById(R.id.gvSystem);
        //create list adapter
        rl_no = (RelativeLayout) view.findViewById(R.id.rl_no);
        llCustom = (LinearLayout) view.findViewById(R.id.llCustom);
        llSystem = (LinearLayout) view.findViewById(R.id.llSystem);
        return view;
    }
项目:Trivia-Knowledge    文件:ArtsGkHardTab.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.f_artsgk_hard, container, false);
    gridview = (GridView) v.findViewById(R.id.gridview);
    Progress= (BootstrapProgressBar) v.findViewById(R.id.Progress);
    progressText = (TextView) v.findViewById(R.id.progressText);
    return v;
}
项目:Android-Practice    文件:ImageGridFragment.java   
public ImageAdapter(Context context) {
    super();
    mContext = context;
    mImageViewLayoutParams = new GridView.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    // Calculate ActionBar height
    TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(
            android.R.attr.actionBarSize, tv, true)) {
        mActionBarHeight = TypedValue.complexToDimensionPixelSize(
                tv.data, context.getResources().getDisplayMetrics());
    }
}
项目:GitHub    文件:ScienceActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_science);
    setupGridView((GridView) findViewById(R.id.gridView));

    findViewById(R.id.bt_back).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}
项目:CXJPadProject    文件:EmoticonPageView.java   
public EmoticonPageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(ResourceUtils.getIdByName(context,"layout","sobot_item_emoticonpage"), this);
    mGvEmotion = (GridView) view.findViewById(ResourceUtils.getIdByName(context,"id", "sobot_gv_emotion"));

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
        mGvEmotion.setMotionEventSplittingEnabled(false);
    }
    mGvEmotion.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    mGvEmotion.setCacheColorHint(0);
    mGvEmotion.setSelector(new ColorDrawable(Color.TRANSPARENT));
    mGvEmotion.setVerticalScrollBarEnabled(false);
}
项目:Trivia-Knowledge    文件:perEasyTab.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.f_per_easy, container, false);
    gridview = (GridView) v.findViewById(R.id.gridview);
    Progress = (BootstrapProgressBar) v.findViewById(R.id.Progress);
    progressText = (TextView) v.findViewById(R.id.progressText);
    return v;
}
项目:GitHub    文件:TagFragment.java   
@Override
public View initView() {
    View view = View.inflate(mContext, R.layout.fragment_tag, null);
    gv_tag = (GridView) view.findViewById(R.id.gv_tag);

    return view;
}
项目:Trivia-Knowledge    文件:GeoHardTab.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.f_geo_hard, container, false);
    gridview = (GridView) v.findViewById(R.id.gridview);
    Progress= (BootstrapProgressBar) v.findViewById(R.id.Progress);
    progressText = (TextView) v.findViewById(R.id.progressText);
    return v;
}
项目:Trivia-Knowledge    文件:ScienceMediumTab.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.f_sci_medium, container, false);
    gridview = (GridView) v.findViewById(R.id.gridview);
    Progress= (BootstrapProgressBar) v.findViewById(R.id.Progress);
    progressText = (TextView) v.findViewById(R.id.progressText);
    return v;
}
项目:boohee_v5.6    文件:PullToRefreshGridView.java   
protected final GridView createRefreshableView(Context context, AttributeSet attrs) {
    GridView gv;
    if (VERSION.SDK_INT >= 9) {
        gv = new InternalGridViewSDK9(context, attrs);
    } else {
        gv = new InternalGridView(context, attrs);
    }
    gv.setId(R.id.gridview);
    return gv;
}
项目:GitHub    文件:ImageGridFragment.java   
public void setItemHeight(int height) {
    if (height == mItemHeight) {
        return;
    }
    mItemHeight = height;
    mImageViewLayoutParams =
            new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mItemHeight);
    notifyDataSetChanged();
}
项目:GitHub    文件:ImageGridFragment.java   
public ImageAdapter(Context context) {
    super();
    mContext = context;
    mImageViewLayoutParams = new GridView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(
            android.R.attr.actionBarSize, tv, true)) {
        mActionBarHeight = TypedValue.complexToDimensionPixelSize(
                tv.data, context.getResources().getDisplayMetrics());
    }
}
项目:Trivia-Knowledge    文件:ArtsGkEasyTab.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.f_artsgk_easy, container, false);
    gridview = (GridView) v.findViewById(R.id.gridview);
    Progress= (BootstrapProgressBar) v.findViewById(R.id.Progress);
    progressText = (TextView) v.findViewById(R.id.progressText);
    return v;
}
项目:Trivia-Knowledge    文件:ArtsGkMediumTab.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.f_artsgk_medium, container, false);
    gridview = (GridView) v.findViewById(R.id.gridview);
    Progress= (BootstrapProgressBar) v.findViewById(R.id.Progress);
    progressText = (TextView) v.findViewById(R.id.progressText);
    return v;
}
项目:TFG-SmartU-La-red-social    文件:AdapterAreasInteres.java   
public AdapterAreasInteres(Bundle savedInstanceState, Context context, Set<Integer> posicionAreasInicial, ArrayList<Area> areasBack, GridView gridView, ArrayList<Area> areasIniciales) {
    this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.context = context;
    this.areas = Almacen.getAreas();
    this.areasBack = areasBack;
    this.gridView=gridView;
    this.areasInicales=areasIniciales;
    this.posicionAreasInicial = posicionAreasInicial;
}
项目:TensorflowAndroidDemo    文件:StylizeActivity.java   
@Override
public void onPreviewSizeChosen(final Size size, final int rotation) {
  final float textSizePx =
      TypedValue.applyDimension(
          TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE_DIP, getResources().getDisplayMetrics());
  borderedText = new BorderedText(textSizePx);
  borderedText.setTypeface(Typeface.MONOSPACE);

  inferenceInterface = new TensorFlowInferenceInterface(getAssets(), MODEL_FILE);

  previewWidth = size.getWidth();
  previewHeight = size.getHeight();

  final Display display = getWindowManager().getDefaultDisplay();
  final int screenOrientation = display.getRotation();

  LOGGER.i("Sensor orientation: %d, Screen orientation: %d", rotation, screenOrientation);

  sensorOrientation = rotation + screenOrientation;

  addCallback(
      new DrawCallback() {
        @Override
        public void drawCallback(final Canvas canvas) {
          renderDebug(canvas);
        }
      });

  adapter = new ImageGridAdapter();
  grid = (GridView) findViewById(R.id.grid_layout);
  grid.setAdapter(adapter);
  grid.setOnTouchListener(gridTouchAdapter);

  setStyle(adapter.items[0], 1.0f);
}
项目:Month_Calendar    文件:MonthCalendar.java   
private void addHeaderView() {
    View header =  LayoutInflater.from(getContext()).inflate(R.layout.layout_calender_header, this, false);
    header.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, headerHeight));
    header.setBackgroundColor(headerBgColor);
    GridView weekGrid = (GridView) header.findViewById(R.id.grid_week);
    addView(header);
    weekGrid.setAdapter(new WeekAdapter(getViewHelper));
    header.setVisibility(showWeek ? VISIBLE : GONE);
}
项目:rongyunDemo    文件:ReadReceiptDetailActivity.java   
public void setGridViewHeight(GridView gridView) {
    if (gridView == null) {
        return;
    }

    ViewGroup.LayoutParams params = gridView.getLayoutParams();

    //获取ActionBar高度
    TypedValue tv = new TypedValue();
    int actionBarHeight = 0;
    if (mContext.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, mContext.getResources().getDisplayMetrics());
    }

    /**
     * 获取状态栏高度
     * */
    int statusBarHeight = 0;
    if (getResources() != null) {
        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            //根据资源ID获取响应的尺寸值
            statusBarHeight = getResources().getDimensionPixelSize(resourceId);
        }
    }
    params.height = getScreenHeight() - getSolidHeight() - actionBarHeight - statusBarHeight;
    // 设置参数
    gridView.setLayoutParams(params);
}
项目:CustomAndroidOneSheeld    文件:PullToRefreshGridView.java   
@Override
protected final GridView createRefreshableView(Context context, AttributeSet attrs) {
    final GridView gv;
    if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        gv = new InternalGridViewSDK9(context, attrs);
    } else {
        gv = new InternalGridView(context, attrs);
    }

    // Use Generated ID (from res/values/ids.xml)
    gv.setId(R.id.gridview);
    return gv;
}
项目:LueansRead    文件:ShowDialog.java   
public void showThemeDialog(final Activity context, final String index){
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.ChangeThemeDialog);
    builder.setTitle("更换主题");
    Integer[] res = new Integer[]{R.drawable.red_round, R.drawable.brown_round, R.drawable.blue_round,
            R.drawable.blue_grey_round, R.drawable.yellow_round, R.drawable.deep_purple_round,
            R.drawable.pink_round, R.drawable.green_round, R.drawable.deep_orange_round,
            R.drawable.grey_round, R.drawable.cyan_round, R.drawable.amber_round};
    List<Integer> list = Arrays.asList(res);
    ColorsListAdapter adapter = new ColorsListAdapter(context, list);
    adapter.setCheckItem(ThemeUtils.getCurrentTheme(context).getIntValue());
    GridView gridView = (GridView) LayoutInflater.from(context).inflate(R.layout.colors_panel_layout, null);
    gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    gridView.setCacheColorHint(0);
    gridView.setAdapter(adapter);
    builder.setView(gridView);
    final AlertDialog dialog = builder.show();
    gridView.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    dialog.dismiss();
                    int value = ThemeUtils.getCurrentTheme(context).getIntValue();
                    Log.d("wxl", "value==" + value);
                    if (value != position) {
                        PreferenceUtils.setPreferenceInt(context,PreferenceUtils.THEME_KEY, position);
                        PreferenceUtils.setPreferenceString(context,PreferenceUtils.MAIN_INDEX_MENU,index);
                        context.getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
                        context.recreate();
                    }
                }
            }
    );
}
项目:ultrasonic    文件:PullToRefreshGridView.java   
@Override
protected final GridView createRefreshableView(Context context, AttributeSet attrs) {
    final GridView gv;
    if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
        gv = new InternalGridViewSDK9(context, attrs);
    } else {
        gv = new InternalGridView(context, attrs);
    }

    // Use Generated ID (from res/values/ids.xml)
    gv.setId(R.id.gridview);
    return gv;
}