use of android.widget.GridView in project DropDownMenu by dongjunkun.
the class MainActivity method initView.
private void initView() {
//init city menu
final ListView cityView = new ListView(this);
cityAdapter = new GirdDropDownAdapter(this, Arrays.asList(citys));
cityView.setDividerHeight(0);
cityView.setAdapter(cityAdapter);
//init age menu
final ListView ageView = new ListView(this);
ageView.setDividerHeight(0);
ageAdapter = new ListDropDownAdapter(this, Arrays.asList(ages));
ageView.setAdapter(ageAdapter);
//init sex menu
final ListView sexView = new ListView(this);
sexView.setDividerHeight(0);
sexAdapter = new ListDropDownAdapter(this, Arrays.asList(sexs));
sexView.setAdapter(sexAdapter);
//init constellation
final View constellationView = getLayoutInflater().inflate(R.layout.custom_layout, null);
GridView constellation = ButterKnife.findById(constellationView, R.id.constellation);
constellationAdapter = new ConstellationAdapter(this, Arrays.asList(constellations));
constellation.setAdapter(constellationAdapter);
TextView ok = ButterKnife.findById(constellationView, R.id.ok);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDropDownMenu.setTabText(constellationPosition == 0 ? headers[3] : constellations[constellationPosition]);
mDropDownMenu.closeMenu();
}
});
//init popupViews
popupViews.add(cityView);
popupViews.add(ageView);
popupViews.add(sexView);
popupViews.add(constellationView);
//add item click event
cityView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
cityAdapter.setCheckItem(position);
mDropDownMenu.setTabText(position == 0 ? headers[0] : citys[position]);
mDropDownMenu.closeMenu();
}
});
ageView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ageAdapter.setCheckItem(position);
mDropDownMenu.setTabText(position == 0 ? headers[1] : ages[position]);
mDropDownMenu.closeMenu();
}
});
sexView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
sexAdapter.setCheckItem(position);
mDropDownMenu.setTabText(position == 0 ? headers[2] : sexs[position]);
mDropDownMenu.closeMenu();
}
});
constellation.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
constellationAdapter.setCheckItem(position);
constellationPosition = position;
}
});
//init context view
TextView contentView = new TextView(this);
contentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
contentView.setText("内容显示区域");
contentView.setGravity(Gravity.CENTER);
contentView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
//init dropdownview
mDropDownMenu.setDropDownMenu(Arrays.asList(headers), popupViews, contentView);
}
use of android.widget.GridView in project PullToRefreshLibrary by harichen.
the class PullToRefreshGridView method createRefreshableView.
@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;
}
use of android.widget.GridView in project Notes by lguipeng.
the class SettingFragment method showThemeChooseDialog.
@Override
public void showThemeChooseDialog() {
AlertDialog.Builder builder = DialogUtils.makeDialogBuilder(activity);
builder.setTitle(R.string.change_theme);
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 };
List<Integer> list = Arrays.asList(res);
ColorsListAdapter adapter = new ColorsListAdapter(getActivity(), list);
adapter.setCheckItem(ThemeUtils.getCurrentTheme(activity).getIntValue());
GridView gridView = (GridView) LayoutInflater.from(activity).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((parent, view, position, id) -> {
dialog.dismiss();
settingPresenter.onThemeChoose(position);
});
}
use of android.widget.GridView in project nmid-headline by miao1007.
the class PlatformListPage method initView.
private void initView() {
View backImageView = findViewByResName("backImageView");
backImageView.setTag(android.R.string.cancel);
backImageView.setOnClickListener(this);
View okImageView = findViewByResName("okImageView");
okImageView.setTag(android.R.string.ok);
okImageView.setOnClickListener(this);
gridViewAdapter = new PlatformGridViewAdapter(activity);
gridViewAdapter.setCustomerLogos(customerLogos);
GridView gridView = (GridView) findViewByResName("gridView");
gridView.setAdapter(gridViewAdapter);
new AsyncTask<Void, Void, Platform[]>() {
@Override
protected Platform[] doInBackground(Void... params) {
return ShareSDK.getPlatformList();
}
@Override
protected void onPostExecute(Platform[] platforms) {
gridViewAdapter.setData(platforms, hiddenPlatforms);
}
}.execute();
}
use of android.widget.GridView in project ion by koush.
the class GallerySample method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Ion.getDefault(this).configure().setLogging("ion-sample", Log.DEBUG);
setContentView(R.layout.gallery);
int cols = getResources().getDisplayMetrics().widthPixels / getResources().getDisplayMetrics().densityDpi * 2;
GridView view = (GridView) findViewById(R.id.results);
view.setNumColumns(cols);
mAdapter = new MyAdapter(this);
view.setAdapter(mAdapter);
loadMore();
}
Aggregations