Java Code Examples for android.widget.GridView

The following are top voted examples for showing how to use android.widget.GridView. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OSchina_resources_android   File: EmojiPageFragment.java   View source code 8 votes vote down vote up
@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;
}
 
Example 2
Project: EmotionApp   File: EmotionComplateFragment.java   View source code 8 votes vote down vote up
/**
 * 创建显示表情的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;
}
 
Example 3
Project: PictureShow   File: TimeLinePage.java   View source code 7 votes vote down vote up
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);
}
 
Example 4
Project: RestaurantApp   File: CategoryFragment.java   View source code 7 votes vote down vote up
@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;
}
 
Example 5
Project: androidadvanced   File: GridViewExampleActivity.java   View source code 7 votes vote down vote up
@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();
    }
}
 
Example 6
Project: EditorImageAndText   File: ImageGridActivity.java   View source code 7 votes vote down vote up
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);
}
 
Example 7
Project: GitHub   File: SwipeRefreshMultipleViewsFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 8
Project: GitHub   File: ColorChooserDialog.java   View source code 6 votes vote down vote up
@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;
}
 
Example 9
Project: GitHub   File: ImageGridFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 10
Project: School1-Android   File: TimetableFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 11
Project: stynico   File: LotteryAPIActivity.java   View source code 6 votes vote down vote up
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);
   }
 
Example 12
Project: Phoenix-for-VK   File: EmojiconGridView.java   View source code 6 votes vote down vote up
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);
}
 
Example 13
Project: airgram   File: EmojiView.java   View source code 6 votes vote down vote up
public void invalidateViews() {
    for (GridView gridView : views) {
        if (gridView != null) {
            gridView.invalidateViews();
        }
    }
}
 
Example 14
Project: HiBangClient   File: EmoteInputView.java   View source code 6 votes vote down vote up
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;
}
 
Example 15
Project: FireFiles   File: DirectoryFragment.java   View source code 6 votes vote down vote up
@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;
}
 
Example 16
Project: EmoticonGIFKeyboard   File: EmoticonGridFragment.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 17
Project: AndroidDigIn   File: ColorMatrixActivity.java   View source code 6 votes vote down vote up
@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();
}
 
Example 18
Project: InstagramManager-Android   File: DetailActivity.java   View source code 6 votes vote down vote up
@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;

}
 
Example 19
Project: Huochexing12306   File: EditImageAty.java   View source code 6 votes vote down vote up
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();
		}
	});
}
 
Example 20
Project: xlight_android_native   File: ScenarioMainFragment.java   View source code 6 votes vote down vote up
@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;
    }
 
Example 21
Project: Trivia-Knowledge   File: ArtsGkHardTab.java   View source code 5 votes vote down vote up
@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;
}
 
Example 22
Project: Android-Practice   File: ImageGridFragment.java   View source code 5 votes vote down vote up
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());
    }
}
 
Example 23
Project: GitHub   File: ScienceActivity.java   View source code 5 votes vote down vote up
@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();
        }
    });
}
 
Example 24
Project: CXJPadProject   File: EmoticonPageView.java   View source code 5 votes vote down vote up
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);
}
 
Example 25
Project: Trivia-Knowledge   File: perEasyTab.java   View source code 5 votes vote down vote up
@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;
}
 
Example 26
Project: GitHub   File: TagFragment.java   View source code 5 votes vote down vote up
@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;
}
 
Example 27
Project: Trivia-Knowledge   File: GeoHardTab.java   View source code 5 votes vote down vote up
@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;
}
 
Example 28
Project: Trivia-Knowledge   File: ScienceMediumTab.java   View source code 5 votes vote down vote up
@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;
}
 
Example 29
Project: boohee_v5.6   File: PullToRefreshGridView.java   View source code 5 votes vote down vote up
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;
}
 
Example 30
Project: GitHub   File: ImageGridFragment.java   View source code 5 votes vote down vote up
public void setItemHeight(int height) {
    if (height == mItemHeight) {
        return;
    }
    mItemHeight = height;
    mImageViewLayoutParams =
            new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mItemHeight);
    notifyDataSetChanged();
}
 
Example 31
Project: GitHub   File: ImageGridFragment.java   View source code 5 votes vote down vote up
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());
    }
}
 
Example 32
Project: Trivia-Knowledge   File: ArtsGkEasyTab.java   View source code 5 votes vote down vote up
@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;
}
 
Example 33
Project: Trivia-Knowledge   File: ArtsGkMediumTab.java   View source code 5 votes vote down vote up
@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;
}
 
Example 34
Project: TFG-SmartU-La-red-social   File: AdapterAreasInteres.java   View source code 5 votes vote down vote up
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;
}
 
Example 35
Project: TensorflowAndroidDemo   File: StylizeActivity.java   View source code 5 votes vote down vote up
@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);
}
 
Example 36
Project: Month_Calendar   File: MonthCalendar.java   View source code 5 votes vote down vote up
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);
}
 
Example 37
Project: rongyunDemo   File: ReadReceiptDetailActivity.java   View source code 5 votes vote down vote up
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);
}
 
Example 38
Project: CustomAndroidOneSheeld   File: PullToRefreshGridView.java   View source code 5 votes vote down vote up
@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;
}
 
Example 39
Project: LueansRead   File: ShowDialog.java   View source code 5 votes vote down vote up
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();
                    }
                }
            }
    );
}
 
Example 40
Project: ultrasonic   File: PullToRefreshGridView.java   View source code 5 votes vote down vote up
@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;
}