Search in sources :

Example 76 with GridView

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);
}
Also used : ViewGroup(android.view.ViewGroup) GridView(android.widget.GridView) InjectView(butterknife.InjectView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView)

Example 77 with GridView

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;
}
Also used : GridView(android.widget.GridView)

Example 78 with GridView

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);
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ColorsListAdapter(com.lguipeng.notes.adpater.ColorsListAdapter) GridView(android.widget.GridView)

Example 79 with GridView

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();
}
Also used : Platform(cn.sharesdk.framework.Platform) GridView(android.widget.GridView) GridView(android.widget.GridView) View(android.view.View)

Example 80 with GridView

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();
}
Also used : GridView(android.widget.GridView)

Aggregations

GridView (android.widget.GridView)142 View (android.view.View)86 AdapterView (android.widget.AdapterView)64 TextView (android.widget.TextView)42 ImageView (android.widget.ImageView)30 AbsListView (android.widget.AbsListView)20 Intent (android.content.Intent)15 ViewGroup (android.view.ViewGroup)14 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)11 SuppressLint (android.annotation.SuppressLint)10 ArrayList (java.util.ArrayList)9 LayoutInflater (android.view.LayoutInflater)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