zoukankan      html  css  js  c++  java
  • ExpandableListView

     //创建一个BaseExpandableListAdapter对象
    ExpandableListAdapter adapter = new BaseExpandableListAdapter()
    {

    public Object getChild(int groupPosition, int childPosition)
    {
    return arms[groupPosition][childPosition];
    }

    @Override
    public long getChildId(int groupPosition, int childPosition)
    {
    return childPosition;
    }

    @Override
    public int getChildrenCount(int groupPosition)
    {
    return arms[groupPosition].length;
    }

    private TextView getTextView()
    {
    AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
    ViewGroup.LayoutParams.MATCH_PARENT, 64);
    TextView textView = new TextView(MainActivity.this);
    textView.setLayoutParams(lp);
    textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    textView.setPadding(36, 0, 0, 0);
    textView.setTextSize(20);
    return textView;
    }


    // 该方法决定每个子选项的外观
    @Override
    public View getChildView(int groupPosition, int childPosition,
    boolean isLastChild, View convertView, ViewGroup parent)
    {
    TextView textView = getTextView();
    textView.setText(getChild(groupPosition, childPosition)
    .toString());
    return textView;
    }


    // 获取指定组位置处的组数据
    @Override
    public Object getGroup(int groupPosition)
    {
    return armTypes[groupPosition];//设置显示数据1
    }
    @Override
    public int getGroupCount()
    {
    return armTypes.length;//设置组长度
    }
    @Override
    public long getGroupId(int groupPosition)
    {
    return groupPosition;//设置组位置
    }


    /*******************************设置可改*****************************************/
    // 该方法决定每个组选项的外观
    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
    View convertView, ViewGroup parent)
    {
    LinearLayout ll = new LinearLayout(MainActivity.this);
    ll.setOrientation(0);
    ImageView logo = new ImageView(MainActivity.this);
    logo.setImageResource(logos[groupPosition]);
    ll.addView(logo);
    TextView textView = getTextView();
    textView.setText(getGroup(groupPosition).toString());
    ll.addView(textView);
    return ll;
    }
    /*************************************8*************************************************/

    @Override
    public boolean isChildSelectable(int groupPosition,
    int childPosition)
    {
    return true;
    }
    @Override
    public boolean hasStableIds()
    {
    return true;
    }
    };
    ExpandableListView expandListView = (ExpandableListView) findViewById(R.id.list);
    expandListView.setAdapter(adapter);
    }


  • 相关阅读:
    十二、redis常用的运维命令及注意参数
    十一,redis的主从集群
    十、redis的持久化配置
    九、Redis的消息发布和订阅
    八、Redis 中的事务
    apache、nginx、iis日志记录的各个字段内容与含义
    Pikachu-RCE
    Pikachu-SQL-Inject(SQL注入漏洞)
    Pikachu-CSRF(跨站请求伪造)
    Pikachu-XSS(跨站脚本)漏洞
  • 原文地址:https://www.cnblogs.com/yhc04161120/p/4816805.html
Copyright © 2011-2022 走看看