Let’s create listView using Custom Adapter rather than using standard adapter “android.R.layout.simple_list_item_1”.
The final look of the application will look like this:
- Firstly, you must decide how the components will be situated, so create items.xml and add needed components. In our case we will add 3 TextViews in file items.xml.
2. Secondly, add ListView component to main activity_main.xml
3. Create Product.java file and add 3 String fields as we have 3 TextView components. Also add Contrustor with parameters and Getters and Setters
4. Create MyAdapter.java file. Extend from ArratAdapter<Product>.
5. MainActivity.java add next code: