use of android.widget.GridView in project LiveLessons by douglascraigschmidt.
the class ResultsActivity method addResultButton.
/**
* Add a button with the given filterName as its text. This
* button will load the results of the given filter into the
* GridView
*/
@SuppressLint("InflateParams")
private void addResultButton(String filterName) {
// Create a new button with the layout of "result_button".
Button resultButton = (Button) LayoutInflater.from(this).inflate(R.layout.result_button, null);
// Set the new button's text and tag to the filter name.
resultButton.setText(filterName);
resultButton.setTag(filterName);
// When the button is clicked, change the imageAdapter source
// to the appropriate filter directory.
resultButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Button button = (Button) view;
// Find the filter directory and load the
// directory as the source of the imageAdapter.
imageAdapter.setBitmaps(new File(Options.instance().getDirectoryPath(), button.getText().toString()).getAbsolutePath());
}
});
// Add the button to the layout.
mLayout.addView(resultButton);
}
use of android.widget.GridView in project android_frameworks_base by DirtyUnicorns.
the class GridScenario method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// turn off title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
mScreenHeight = getWindowManager().getDefaultDisplay().getHeight();
final Params params = new Params();
init(params);
readAndValidateParams(params);
mGridView = new GridView(this);
mGridView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mGridView.setDrawSelectorOnTop(false);
if (mNumColumns >= GridView.AUTO_FIT) {
mGridView.setNumColumns(mNumColumns);
}
if (mColumnWidth > 0) {
mGridView.setColumnWidth(mColumnWidth);
}
if (mVerticalSpacing > 0) {
mGridView.setVerticalSpacing(mVerticalSpacing);
}
mGridView.setStretchMode(mStretchMode);
mGridView.setAdapter(createAdapter());
if (mStartingSelectionPosition >= 0) {
mGridView.setSelection(mStartingSelectionPosition);
}
mGridView.setPadding(10, 10, 10, 10);
mGridView.setStackFromBottom(mStackFromBottom);
mGridView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView parent, View v, int position, long id) {
positionSelected(position);
}
public void onNothingSelected(AdapterView parent) {
nothingSelected();
}
});
setContentView(mGridView);
}
use of android.widget.GridView in project CurtainView by aicaprio.
the class MainActivity method showSample2.
private void showSample2() {
setContentView(R.layout.activity_sample2);
final CurtainView curtainView = (CurtainView) findViewById(R.id.cb1);
final ImageView iv1 = (ImageView) findViewById(R.id.iv1);
final GridView gv1 = (GridView) findViewById(R.id.gv1);
final List<Map<String, Integer>> data = getData();
gv1.setAdapter(new SimpleAdapter(this, data, R.layout.item_numbers, new String[] { TEXT_TAG }, new int[] { R.id.item_tvNum }));
gv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
showToast(data.get(position).get(TEXT_TAG) + " clicked");
}
});
iv1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
curtainView.toggleStatus();
}
});
curtainView.setScrollerInterpolator(new BounceInterpolator());
curtainView.post(new Runnable() {
@Override
public void run() {
curtainView.setCurtainGravityAndFixedValue(null, iv1.getHeight());
}
});
}
use of android.widget.GridView in project emojicon by rockerhieu.
the class EmojiconGridFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
Bundle bundle = getArguments();
if (bundle == null) {
mEmojiconType = Emojicon.TYPE_UNDEFINED;
mEmojicons = People.DATA;
mUseSystemDefault = false;
} else {
// noinspection WrongConstant
mEmojiconType = bundle.getInt(ARG_EMOJICON_TYPE);
if (mEmojiconType == Emojicon.TYPE_UNDEFINED) {
Parcelable[] parcels = bundle.getParcelableArray(ARG_EMOJICONS);
mEmojicons = new Emojicon[parcels.length];
for (int i = 0; i < parcels.length; i++) {
mEmojicons[i] = (Emojicon) parcels[i];
}
} else {
mEmojicons = Emojicon.getEmojicons(mEmojiconType);
}
mUseSystemDefault = bundle.getBoolean(ARG_USE_SYSTEM_DEFAULTS);
}
gridView.setAdapter(new EmojiconAdapter(view.getContext(), mEmojicons, mUseSystemDefault));
gridView.setOnItemClickListener(this);
}
use of android.widget.GridView in project SmartCampus by Vegen.
the class EaseEmojiconPagerView method getGroupGridViews.
/**
* get emojicon group gridview list
* @param groupEntity
* @return
*/
public List<View> getGroupGridViews(EaseEmojiconGroupEntity groupEntity) {
List<EaseEmojicon> emojiconList = groupEntity.getEmojiconList();
int itemSize = emojiconColumns * emojiconRows - 1;
int totalSize = emojiconList.size();
Type emojiType = groupEntity.getType();
if (emojiType == Type.BIG_EXPRESSION) {
itemSize = bigEmojiconColumns * bigEmojiconRows;
}
int pageSize = totalSize % itemSize == 0 ? totalSize / itemSize : totalSize / itemSize + 1;
List<View> views = new ArrayList<View>();
for (int i = 0; i < pageSize; i++) {
View view = View.inflate(context, R.layout.ease_expression_gridview, null);
GridView gv = (GridView) view.findViewById(R.id.gridview);
if (emojiType == Type.BIG_EXPRESSION) {
gv.setNumColumns(bigEmojiconColumns);
} else {
gv.setNumColumns(emojiconColumns);
}
List<EaseEmojicon> list = new ArrayList<EaseEmojicon>();
if (i != pageSize - 1) {
list.addAll(emojiconList.subList(i * itemSize, (i + 1) * itemSize));
} else {
list.addAll(emojiconList.subList(i * itemSize, totalSize));
}
if (emojiType != Type.BIG_EXPRESSION) {
EaseEmojicon deleteIcon = new EaseEmojicon();
deleteIcon.setEmojiText(EaseSmileUtils.DELETE_KEY);
list.add(deleteIcon);
}
final EmojiconGridAdapter gridAdapter = new EmojiconGridAdapter(context, 1, list, emojiType);
gv.setAdapter(gridAdapter);
gv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
EaseEmojicon emojicon = gridAdapter.getItem(position);
if (pagerViewListener != null) {
String emojiText = emojicon.getEmojiText();
if (emojiText != null && emojiText.equals(EaseSmileUtils.DELETE_KEY)) {
pagerViewListener.onDeleteImageClicked();
} else {
pagerViewListener.onExpressionClicked(emojicon);
}
}
}
});
views.add(view);
}
return views;
}
Aggregations