开发者

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

开发者 https://www.devze.com 2023-02-22 10:59 出处:网络
How can 开发者_JAVA百科I accomplish this without extending BaseAdapter?final int count = array.size();

How can 开发者_JAVA百科I accomplish this without extending 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());
            }
        });
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消