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;
}
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);
}
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;
}
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);
}
});
}
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());
}
Aggregations