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   Source Code and License 9 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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 41
Project: financisto1-holo   File: QuickActionGrid.java   Source Code and License 5 votes vote down vote up
public QuickActionGrid(Context context) {
    super(context);

    setContentView(R.layout.gd_quick_action_grid);

    final View v = getContentView();
    mGridView = (GridView) v.findViewById(R.id.gdi_grid);
}
 
Example 42
Project: CircoIconPack   File: ApplyLauncherFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container_launcher,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.apply_launcher_behind, null);
    gridView = (GridView) view.findViewById(R.id.grid);
    return view;
}
 
Example 43
Project: yyox   File: EmoticonPageView.java   Source Code and License 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(R.layout.kf5_emoticon_page, this);
    mGvEmotion = (GridView) view.findViewById(R.id.kf5_grid_view_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 44
Project: FanChat   File: EaseChatExtendMenu.java   Source Code and License 5 votes vote down vote up
private void init(Context context, AttributeSet attrs){
    this.context = context;
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.EaseChatExtendMenu);
    int numColumns = ta.getInt(R.styleable.EaseChatExtendMenu_numColumns, 4);
    ta.recycle();
    
    setNumColumns(numColumns);
    setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    setGravity(Gravity.CENTER_VERTICAL);
    setVerticalSpacing(DensityUtil.dip2px(context, 8));
}
 
Example 45
Project: yyox   File: ImageSelectorFragment.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.kf5_fragment_multi_image, null, false);
    mCategoryText = (TextView) view.findViewById(R.id.kf5_category_btn);
    mGridView = (GridView) view.findViewById(R.id.kf5_selector_gridview);
    return view;
}
 
Example 46
Project: Botanist   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        getSupportActionBar().setIcon(R.drawable.ic_logo_botanist);
    }
    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        /**
         * Handle action button click
         * @param view - current view
         */
        @Override
        public void onClick(View view) {
            startActivity(new Intent(MainActivity.this, NewPlantActivity.class));
        }
    });
    View tipView = findViewById(R.id.daily_tip_cardview);
    tipView.findViewById(R.id.daily_tip_dismiss_button).setOnClickListener(new View.OnClickListener() {
        /**
         * change visibility of CardView to gone if user clicked "Dismiss" button
         * @param v - the view
         */
        @Override
        public void onClick(View v) {
            findViewById(R.id.daily_tip_cardview).setVisibility(View.GONE);
        }
    });
    GridView gridView = findViewById(R.id.plants_grid);
    gridView.setEmptyView(findViewById(R.id.empty_grid_view));
    mController = new MainController(this);
    AppRater.INSTANCE.appLaunched(this);
}
 
Example 47
Project: ywApplication   File: PullToRefreshGridView.java   Source Code and License 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 48
Project: friendlypix-android   File: UserDetailActivity.java   Source Code and License 5 votes vote down vote up
@Override
public GridImageHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ImageView imageView = new ImageView(UserDetailActivity.this);
    int tileDimPx = getPixelsFromDps(100);
    imageView.setLayoutParams(new GridView.LayoutParams(tileDimPx, tileDimPx));
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setPadding(8, 8, 8, 8);

    return new GridImageHolder(imageView);
}
 
Example 49
Project: CP-Tester   File: SchemaFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    provider = getArguments().getParcelable(ARG_PROVIDER);
    String result = getSQLResult(getContext(), provider, getString(R.string.sql_injection));
    View rootView = inflater.inflate(R.layout.fragment_details_schema, container, false);
    if (getStatus(result)==100){
        //TODO add image view
        rootView.findViewById(R.id.tv_schema).setVisibility(View.VISIBLE);
    } else {
        LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.ll);
        Map<String, List<List<String>>> resultToMap = parseResultToMap(result);
        for (String name: resultToMap.keySet()){
            TextView tv = getFilledTextView(getContext(),name);
            linearLayout.addView(tv);
            GridView grid = new GridView(getContext());
            grid.setNumColumns(3);
            grid.setHorizontalSpacing(10);
            grid.setVerticalSpacing(10);
            grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
            grid.setGravity(View.TEXT_ALIGNMENT_CENTER);
            List<List<String>> list = resultToMap.get(name);
            grid.setAdapter(new GridAdapter(getContext(),list));
            grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, list.size()*35)); //TODO: remove int value
            linearLayout.addView(grid);
        }
    }
    return rootView;
}
 
Example 50
Project: Guanajoven   File: ExtendedCalendarView.java   Source Code and License 5 votes vote down vote up
private void init(){
	cal = Calendar.getInstance();
	base = new RelativeLayout(context);
	base.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
	base.setMinimumHeight(50);
	
	base.setId(4);
	
	LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.leftMargin = 16;
	params.topMargin = 50;
	params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	prev = new ImageView(context);
	prev.setId(1);
	prev.setLayoutParams(params);
	prev.setImageResource(R.drawable.navigation_previous_item);
	prev.setOnClickListener(this);
	base.addView(prev);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.addRule(RelativeLayout.CENTER_HORIZONTAL);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	month = new TextView(context);
	month.setId(2);
	month.setLayoutParams(params);
	month.setTextAppearance(context, android.R.attr.textAppearanceLarge);
	month.setText(cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())+" "+cal.get(Calendar.YEAR));
	month.setTextSize(25);
	
	base.addView(month);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.rightMargin = 16;
	params.topMargin = 50;
	params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	next = new ImageView(context);
	next.setImageResource(R.drawable.navigation_next_item);
	next.setLayoutParams(params);
	next.setId(3);
	next.setOnClickListener(this);
	
	base.addView(next);
	
	addView(base);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.bottomMargin = 20;
	params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	params.addRule(RelativeLayout.BELOW, base.getId());
	
	calendar = new GridView(context);
	calendar.setLayoutParams(params);
	calendar.setVerticalSpacing(4);
	calendar.setHorizontalSpacing(4);
	calendar.setNumColumns(7);
	calendar.setChoiceMode(GridView.CHOICE_MODE_SINGLE);
	calendar.setDrawSelectorOnTop(true);
	calendar.setFocusable(false);

	mAdapter = new CalendarAdapter(context,cal);
	calendar.setAdapter(mAdapter);
	calendar.setOnTouchListener(new OnTouchListener() {
		
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return calendarGesture.onTouchEvent(event);
        }
    });

	addView(calendar);
}
 
Example 51
Project: tv_move_gridView   File: DragGridView.java   Source Code and License 5 votes vote down vote up
/**
 * 手指抬起时,item下落
 */
private void itemDrop() {
    if (tempPosition == position || tempPosition == GridView.INVALID_POSITION) {
        getChildAt(position).setVisibility(VISIBLE);
    } else {
        ListAdapter adapter = getAdapter();
        if (adapter != null && adapter instanceof DragGridAdapter) {
            ((DragGridAdapter) adapter).exchangePosition(position, tempPosition, false);
        }
    }
}
 
Example 52
Project: GCSApp   File: EaseChatExtendMenu.java   Source Code and License 5 votes vote down vote up
private void init(Context context, AttributeSet attrs){
    this.context = context;
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.EaseChatExtendMenu);
    int numColumns = ta.getInt(R.styleable.EaseChatExtendMenu_numColumns, 4);
    ta.recycle();
    
    setNumColumns(numColumns);
    setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    setGravity(Gravity.CENTER_VERTICAL);
    setVerticalSpacing(DensityUtil.dip2px(context, 8));
}
 
Example 53
Project: Android-DFU-App   File: FeaturesActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_features);

       final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
       setSupportActionBar(toolbar);

	// ensure that Bluetooth exists
	if (!ensureBLEExists())
		finish();

	final DrawerLayout drawer = mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
	drawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

	// Set the drawer toggle as the DrawerListener
	mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
           @Override
           public void onDrawerSlide(final View drawerView, final float slideOffset) {
               // Disable the Hamburger icon animation
               super.onDrawerSlide(drawerView, 0);
           }
       };
	drawer.setDrawerListener(mDrawerToggle);

	// setup plug-ins in the drawer
	setupPluginsInDrawer((ViewGroup) drawer.findViewById(R.id.plugin_container));

	// configure the app grid
	final GridView grid = (GridView) findViewById(R.id.grid);
	grid.setAdapter(new AppAdapter(this));
	grid.setEmptyView(findViewById(android.R.id.empty));

	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example 54
Project: PinTuGame   File: PuzzleMain.java   Source Code and License 5 votes vote down vote up
private void initViews() {
    mBtnBack = (Button) findViewById(R.id.btn_puzzle_main_back);
    mBtnImage = (Button) findViewById(R.id.btn_puzzle_main_img);
    mBtnRestart = (Button) findViewById(R.id.btn_puzzle_main_restart);
    //flag是否显示原图
    mIsShowImg = false;
    mGvPuzzleMainDetail = (GridView) findViewById(
            R.id.gv_puzzle_main_detail);
            // 设置为N*N显示
    mGvPuzzleMainDetail.setNumColumns(TYPE);
    RelativeLayout.LayoutParams gridParams = new RelativeLayout.LayoutParams(mPicSelected.getWidth(),mPicSelected.getHeight());
    //水平居中
    gridParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    //其他格式属性
    gridParams.addRule(RelativeLayout.BELOW,R.id.ll_puzzle_main_spinner);
    //Grid显示
    mGvPuzzleMainDetail.setLayoutParams(gridParams);
    mGvPuzzleMainDetail.setHorizontalSpacing(0);
    mGvPuzzleMainDetail.setVerticalSpacing(0);
    //TV步数
    mTvPuzzleMainCounts = (TextView) findViewById(R.id.tv_puzzle_main_counts);
    mTvPuzzleMainCounts.setText(""+ COUNT_INDEX);
    //Tv计时器
    mTvTimer = (TextView) findViewById(R.id.tv_puzzle_main_time);
    mTvTimer.setText("0秒");
    //添加显示的原图
    addImgView();

}
 
Example 55
Project: ImageClassify   File: ShowFinishedTaskDetailActivity.java   Source Code and License 5 votes vote down vote up
private void setTaskDetail() {
    CommonAdapter<FinishedTaskImageDetail> taskItemDetailAdapter = new CommonAdapter<FinishedTaskImageDetail>(this, R.layout.finished_task_detail_item, taskList) {
        @Override
        protected void convert(ViewHolder viewHolder, FinishedTaskImageDetail item, int position) {
            ImageView taskImageView = viewHolder.getView(R.id.id_finished_task_image_view);
            Glide.with(ShowFinishedTaskDetailActivity.this)
                    .load(item.getImg_path())
                    .placeholder(R.drawable.ic_user_default_avatar)
                    .centerCrop()
                    .dontAnimate()
                    .into(taskImageView);
            mShowFinishedTaskDetailPresenter.getLabels(item.getUser_labels(), item.getFinal_labels());
            if (confirmLabels.size() != 0) {
                GridView confirmLabelGridView = viewHolder.getView(R.id.id_confirm_task_label_grid_view);
                confirmLabelGridView.setAdapter(new ArrayAdapter<>(ShowFinishedTaskDetailActivity.this,
                        R.layout.confirm_task_label, confirmLabels));
            }
            if (unconfirmLabels.size() != 0) {
                GridView unconfirmLabelGridView = viewHolder.getView(R.id.id_unconfirm_task_label_grid_view);
                unconfirmLabelGridView.setAdapter(new ArrayAdapter<>(ShowFinishedTaskDetailActivity.this,
                        R.layout.unconfirm_task_label, unconfirmLabels));
            }
            TextView accuracyTextView =  viewHolder.getView(R.id.id_image_accuracy);
            if(TextUtils.isEmpty(item.getAccuracy()) || item.getAccuracy().equals("null")){
                accuracyTextView.setText("准确度 0.0%");
            }else {
                String accuracyStr = String.format("%.1f",100*Float.parseFloat(item.getAccuracy()));
                accuracyTextView.setText("准确度 "+ accuracyStr+"%");
            }
        }
    };
    finishedTaskGridView.setAdapter(taskItemDetailAdapter);
}
 
Example 56
Project: Trivia-Knowledge   File: EnterHardTab.java   Source Code and License 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_enter_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 57
Project: APIJSON-Android-RxJava   File: UserActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void initView() {//必须调用

	//添加用户名片,这些方式都可<<<<<<<<<<<<<<<<<<<<<<
	//		//方式一
	//		bvlUser = (BaseViewLayout<User>) findViewById(R.id.bvlUser);
	//		bvlUser.createView(new UserView(context, getResources()));
	//
	//		//方式二
	//		uvlUser = (UserViewLayout) findViewById(R.id.uvlUser);

	//方式三
	llUserBusinessCardContainer = (ViewGroup) findViewById(R.id.llUserBusinessCardContainer);
	llUserBusinessCardContainer.removeAllViews();

	userView = new UserView(context, getResources());
	llUserBusinessCardContainer.addView(userView.createView(getLayoutInflater()));
	//添加用户名片,这些方式都可>>>>>>>>>>>>>>>>>>>>>>>


	llUserMoment = findViewById(R.id.llUserMoment);
	gvUserMoment = (GridView) findViewById(R.id.gvUserMoment);

	tvUserRemark = (TextView) findViewById(R.id.tvUserRemark);
	tvUserTag = (TextView) findViewById(R.id.tvUserTag);

	llUserMoment.setVisibility(isOnEditMode ? View.GONE : View.VISIBLE);
	if (isOnEditMode == false) {
		//添加底部菜单<<<<<<<<<<<<<<<<<<<<<<
		llUserBottomMenuContainer = (ViewGroup) findViewById(R.id.llUserBottomMenuContainer);
		llUserBottomMenuContainer.removeAllViews();

		bottomMenuView = new BottomMenuView(context, getResources(), REQUEST_TO_BOTTOM_MENU);
		llUserBottomMenuContainer.addView(bottomMenuView.createView(getLayoutInflater()));
		//添加底部菜单>>>>>>>>>>>>>>>>>>>>>>>
	}

}
 
Example 58
Project: Hitalk   File: ChatExtendMenuLayout.java   Source Code and License 5 votes vote down vote up
private void init(Context context, AttributeSet attrs){
    this.context = context;
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ChatExtendMenu);
    int numColumns = ta.getInt(R.styleable.ChatExtendMenu_numColumns, 4);
    ta.recycle();
    
    setNumColumns(numColumns);
    setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
    setGravity(Gravity.CENTER_VERTICAL);
    setVerticalSpacing(DisplayUtil.dip2px(context, 8));
}
 
Example 59
Project: CXJPadProject   File: ImageGridAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
    int type = getItemViewType(i);
    if (type == TYPE_CAMERA) {
        view = mInflater.inflate(R.layout.image_picker_list_item_camera, viewGroup, false);
        view.setTag(null);
    }
    else if (type == TYPE_NORMAL) {
        ViewHolder holder;
        if (view == null) {
            view = mInflater.inflate(R.layout.image_picker_list_item_image, viewGroup, false);
            holder = new ViewHolder(view);
        }
        else {
            holder = (ViewHolder) view.getTag();
            if (holder == null) {
                view = mInflater.inflate(R.layout.image_picker_list_item_image, viewGroup, false);
                holder = new ViewHolder(view);
            }
        }
        if (holder != null) {
            holder.bindData(getItem(i));
        }
    }

    /** Fixed View Size */
    GridView.LayoutParams lp = (GridView.LayoutParams) view.getLayoutParams();
    if (lp.height != mItemSize) {
        view.setLayoutParams(mItemLayoutParams);
    }

    return view;
}
 
Example 60
Project: easyfilemanager   File: DirectoryFragment.java   Source Code and License 5 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;
}