Search in sources :

Example 26 with GridView

use of android.widget.GridView in project Fast-Android-Networking by amitshekhariitbhu.

the class ImageGridFragment method onCreateView.

@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;
}
Also used : GridView(android.widget.GridView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) AbsListView(android.widget.AbsListView) ANImageView(com.androidnetworking.widget.ANImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ViewTreeObserver(android.view.ViewTreeObserver) TargetApi(android.annotation.TargetApi)

Example 27 with GridView

use of android.widget.GridView in project platform_frameworks_base by android.

the class CharacterPickerDialog method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.token = mView.getApplicationWindowToken();
    params.type = params.TYPE_APPLICATION_ATTACHED_DIALOG;
    params.flags = params.flags | Window.FEATURE_NO_TITLE;
    setContentView(R.layout.character_picker);
    GridView grid = (GridView) findViewById(R.id.characterPicker);
    grid.setAdapter(new OptionsAdapter(getContext()));
    grid.setOnItemClickListener(this);
    mCancelButton = (Button) findViewById(R.id.cancel);
    mCancelButton.setOnClickListener(this);
}
Also used : GridView(android.widget.GridView) WindowManager(android.view.WindowManager)

Example 28 with GridView

use of android.widget.GridView in project android-Ultra-Pull-To-Refresh by liaohuqiu.

the class WithGridView method createView.

@Override
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHeaderTitle(R.string.ptr_demo_block_grid_view);
    mImageLoader = ImageLoaderFactory.create(getContext());
    final View contentView = inflater.inflate(R.layout.fragment_classic_header_with_gridview, null);
    final GridView gridListView = (GridView) contentView.findViewById(R.id.rotate_header_grid_view);
    gridListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position >= 0) {
                final String url = mAdapter.getItem(position).optString("pic");
                if (!TextUtils.isEmpty(url)) {
                    getContext().pushFragmentToBackStack(MaterialStyleFragment.class, url);
                }
            }
        }
    });
    mAdapter = new ListViewDataAdapter<JsonData>(new ViewHolderCreator<JsonData>() {

        @Override
        public ViewHolderBase<JsonData> createViewHolder(int position) {
            return new ViewHolder();
        }
    });
    gridListView.setAdapter(mAdapter);
    mPtrFrame = (PtrClassicFrameLayout) contentView.findViewById(R.id.rotate_header_grid_view_frame);
    mPtrFrame.setLastUpdateTimeRelateObject(this);
    mPtrFrame.setPtrHandler(new PtrHandler() {

        @Override
        public void onRefreshBegin(PtrFrameLayout frame) {
            updateData();
        }

        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return PtrDefaultHandler.checkContentCanBePulledDown(frame, content, header);
        }
    });
    // the following are default settings
    mPtrFrame.setResistance(1.7f);
    mPtrFrame.setRatioOfHeaderHeightToRefresh(1.2f);
    mPtrFrame.setDurationToClose(200);
    mPtrFrame.setDurationToCloseHeader(1000);
    // default is false
    mPtrFrame.setPullToRefresh(false);
    // default is true
    mPtrFrame.setKeepHeaderWhenRefresh(true);
    mPtrFrame.postDelayed(new Runnable() {

        @Override
        public void run() {
        // mPtrFrame.autoRefresh();
        }
    }, 100);
    // updateData();
    setupViews(mPtrFrame);
    return contentView;
}
Also used : PtrHandler(in.srain.cube.views.ptr.PtrHandler) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) GridView(android.widget.GridView) CubeImageView(in.srain.cube.image.CubeImageView) View(android.view.View) AdapterView(android.widget.AdapterView) JsonData(in.srain.cube.request.JsonData) MaterialStyleFragment(in.srain.cube.views.ptr.demo.ui.MaterialStyleFragment) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView) ViewHolderCreator(in.srain.cube.views.list.ViewHolderCreator)

Example 29 with GridView

use of android.widget.GridView in project TwinklingRefreshLayout by lcodecorex.

the class ScienceActivity method setupGridView.

private void setupGridView(GridView gridView) {
    final TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
    SinaRefreshView headerView = new SinaRefreshView(this);
    headerView.setArrowResource(R.drawable.arrow);
    headerView.setTextColor(0xff745D5C);
    //        TextHeaderView headerView = (TextHeaderView) View.inflate(this,R.layout.header_tv,null);
    refreshLayout.setHeaderView(headerView);
    LoadingView loadingView = new LoadingView(this);
    refreshLayout.setBottomView(loadingView);
    adapter = new ScienceAdapter();
    gridView.setAdapter(adapter);
    adapter.refreshCard();
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            ToastUtil.show("item clicked!");
        }
    });
    refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {

        @Override
        public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    adapter.refreshCard();
                    refreshLayout.finishRefreshing();
                }
            }, 2000);
        }

        @Override
        public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    adapter.loadMoreCard();
                    refreshLayout.finishLoadmore();
                }
            }, 2000);
        }
    });
}
Also used : SinaRefreshView(com.lcodecore.tkrefreshlayout.header.SinaRefreshView) ScienceAdapter(com.lcodecore.twinklingrefreshlayout.adapter.ScienceAdapter) Handler(android.os.Handler) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) SinaRefreshView(com.lcodecore.tkrefreshlayout.header.SinaRefreshView) LoadingView(com.lcodecore.tkrefreshlayout.footer.LoadingView) TwinklingRefreshLayout(com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout) RefreshListenerAdapter(com.lcodecore.tkrefreshlayout.RefreshListenerAdapter) LoadingView(com.lcodecore.tkrefreshlayout.footer.LoadingView) AdapterView(android.widget.AdapterView)

Example 30 with GridView

use of android.widget.GridView in project MultiImageSelector by lovetuzitong.

the class MultiImageSelectorFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final int mode = selectMode();
    if (mode == MODE_MULTI) {
        ArrayList<String> tmp = getArguments().getStringArrayList(EXTRA_DEFAULT_SELECTED_LIST);
        if (tmp != null && tmp.size() > 0) {
            resultList = tmp;
        }
    }
    mImageAdapter = new ImageGridAdapter(getActivity(), showCamera(), 3);
    mImageAdapter.showSelectIndicator(mode == MODE_MULTI);
    mPopupAnchorView = view.findViewById(R.id.footer);
    mCategoryText = (TextView) view.findViewById(R.id.category_btn);
    mCategoryText.setText(R.string.mis_folder_all);
    mCategoryText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mFolderPopupWindow == null) {
                createPopupFolderList();
            }
            if (mFolderPopupWindow.isShowing()) {
                mFolderPopupWindow.dismiss();
            } else {
                mFolderPopupWindow.show();
                int index = mFolderAdapter.getSelectIndex();
                index = index == 0 ? index : index - 1;
                mFolderPopupWindow.getListView().setSelection(index);
            }
        }
    });
    mGridView = (GridView) view.findViewById(R.id.grid);
    mGridView.setAdapter(mImageAdapter);
    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (mImageAdapter.isShowCamera()) {
                if (i == 0) {
                    showCameraAction();
                } else {
                    Image image = (Image) adapterView.getAdapter().getItem(i);
                    selectImageFromGrid(image, mode);
                }
            } else {
                Image image = (Image) adapterView.getAdapter().getItem(i);
                selectImageFromGrid(image, mode);
            }
        }
    });
    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (scrollState == SCROLL_STATE_FLING) {
                Picasso.with(view.getContext()).pauseTag(TAG);
            } else {
                Picasso.with(view.getContext()).resumeTag(TAG);
            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }
    });
    mFolderAdapter = new FolderAdapter(getActivity());
}
Also used : ImageGridAdapter(me.nereo.multi_image_selector.adapter.ImageGridAdapter) AbsListView(android.widget.AbsListView) Image(me.nereo.multi_image_selector.bean.Image) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) Point(android.graphics.Point) FolderAdapter(me.nereo.multi_image_selector.adapter.FolderAdapter) AdapterView(android.widget.AdapterView)

Aggregations

GridView (android.widget.GridView)139 View (android.view.View)83 AdapterView (android.widget.AdapterView)61 TextView (android.widget.TextView)41 ImageView (android.widget.ImageView)28 AbsListView (android.widget.AbsListView)20 Intent (android.content.Intent)14 ViewGroup (android.view.ViewGroup)14 SuppressLint (android.annotation.SuppressLint)10 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)10 LayoutInflater (android.view.LayoutInflater)8 ArrayList (java.util.ArrayList)8 WindowManager (android.view.WindowManager)7 Button (android.widget.Button)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 ListView (android.widget.ListView)6 LinearLayout (android.widget.LinearLayout)5 Bundle (android.os.Bundle)4 ViewTreeObserver (android.view.ViewTreeObserver)4 ArrayAdapter (android.widget.ArrayAdapter)4