zoukankan      html  css  js  c++  java
  • ListPopupWindow

    宽度一般是控件的宽度: mListPopupWindow.setAnchorView(compoundButton);

      check_down.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    mListPopupWindow.setAnchorView(compoundButton);
                    if(b) {
                        mListPopupWindow.show();
                    }else{
                        mListPopupWindow.dismiss();
                    }
                }
            });
    

      

     private void initDialog(){
            final String itmes[]={"第一个子项","第二个子项","第三个子项"};
            mListPopupWindow=new ListPopupWindow(getActivity());
            mListPopupWindow.setAdapter(new ArrayAdapter<String>(getActivity(),R.layout.print_pop_item, itmes));
            mListPopupWindow.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
                    Toast.makeText(getActivity(), "点击了"+itmes[position], Toast.LENGTH_SHORT).show();
                }
            });
        }
    

      

    print_pop_item.xml

    <?xml version="1.0" encoding="utf-8"?>
        <TextView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/btn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />
    

      

  • 相关阅读:
    xadmin 安装
    Python
    使用免费证书安装 ipa 到真机
    Jupyter PPT
    Javascript注意点
    论文哪里找?
    神经网络术语
    PyTorch上路
    DCGAN实现
    数据库和数据挖掘领域的会议和期刊
  • 原文地址:https://www.cnblogs.com/pengmn/p/15241643.html
Copyright © 2011-2022 走看看