Search in sources :

Example 1 with ConstellationAdapter

use of com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.ConstellationAdapter in project JustAndroid by chinaltz.

the class DropMenuActivity 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 : ConstellationAdapter(com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.ConstellationAdapter) ViewGroup(android.view.ViewGroup) GridView(android.widget.GridView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) GirdDropDownAdapter(com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.GirdDropDownAdapter) ListView(android.widget.ListView) ListDropDownAdapter(com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.ListDropDownAdapter) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView)

Aggregations

View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 ConstellationAdapter (com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.ConstellationAdapter)1 GirdDropDownAdapter (com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.GirdDropDownAdapter)1 ListDropDownAdapter (com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.ListDropDownAdapter)1