How to construct and display the info in simple_list_item_2?

后端 未结 2 799
名媛妹妹
名媛妹妹 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:42

    Check out this tutorial on how to create a custom listView. Being a beginner it starts you from the new project stage, I think it would help you. As for what you should use instead of your toString() method, just create in your Customer class some getters to retrieve the data. Something like this:

    public String getName(){
    return this.name;
    }
    

    And use it in your code like this:

     Customer x = new Customer();
    //return the customer name into a string, obviously you will return it in a list that you will pass it to the listview
    String customerName = x.getName();
    

提交回复
热议问题