简体   繁体   English

如何借助Layout Inflater创建截面listview?

[英]How to create the sectional listview with the help of Layout Inflater?

如何在不扩展BaseAdapter情况下完成此BaseAdapter

        final int count = array.size();

    /* layout to draw  list */
    LinearLayout list = (LinearLayout) findViewById(R.id.list);

    LayoutInflater mInflater = null;
    mInflater = LayoutInflater.from(this);

    for (int i = 0; i < count; i++) {

        /* row of the  list  - XML File */
        View convertView = mInflater.inflate(R.layout.item_list, null);

        /* holder class to hold row information to display on screen */
        Holder holder = new Holder();

        convertView.setId(array.get(i).getId());

        holder.icon = (ImageView) convertView.findViewById(R.id.icon);

        holder.iconName = (TextView) convertView.findViewById(R.id.name);

        holder.msg = (TextView) convertView.findViewById(R.id.msg);

        convertView.setTag(holder);

        RelativeLayout.LayoutParams parms = new RelativeLayout.LayoutParams(48, 48);
        holder.icon.setLayoutParams(parms);

        holder.iconName.setText( " your code " );

        holder.msg.setText(" your message ");

        /* add row to the list */
        list.addView(convertView);

        convertView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                /* show details */
                showDetails(v.getId());
            }
        });
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM