How to construct and display the info in simple_list_item_2?

后端 未结 2 804
名媛妹妹
名媛妹妹 2020-12-17 06:21

I get the list of customer info from my (testing) database, and I want to display it. The customer is represented by the Customer class with name,

2条回答
  •  余生分开走
    2020-12-17 06:47

    You can override the getView method of the ArrayAdapter:

      new ArrayAdapter (context, android.R.layout.simple_list_item_2, android.R.id.text1, list)
      {
        public View getView(int position, View convertView, ViewGroup parent) {
          View view = super.getView(position, convertView, parent);
          TextView text1 = (TextView) view.findViewById(android.R.id.text1);
          TextView text2 = (TextView) view.findViewById(android.R.id.text2);
          text1.setText("1");
          text2.setText("2");
          return view;
        }
      })
    

提交回复
热议问题