How to create my above listview to look more professional?

前端 未结 5 693
醉酒成梦
醉酒成梦 2020-12-12 07:43

Can someone tell me how should am i going to create my listview which look similar [here][1].

Problem: How am i going to fulfill the sort of look and feel in my cod

5条回答
  •  萌比男神i
    2020-12-12 08:00

    You haven't create custom adapter to incorporate the layout into codes listview. Here is something you can use

    private class ListViewAdapter extends ArrayAdapter {
            private ArrayList items;
    
            public ListViewAdapter(Context context, int textViewResourceId,
                    ArrayList items) {
                super(context, textViewResourceId, items);
                this.items = items;
    
            }
    
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                Object info = items.get(position);
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.row, null);
                }
    
                if (info != null) {
                    ImageView imView = (ImageView) v.findViewById(R.id.icon);
                    TextView txtname =(TextView) v.findViewById(R.id.toptext);
                    TextView txtAddr = (TextView) v.findViewById(R.id.bottomtext);
                    //set image and set text as you like
                }
                return v;
            }
        }
    
    
    

    Hope this can help.

    提交回复
    热议问题