Step 1
Make a simple project with empty activity and then in the main activity design one button and add one layout and one activity for showing a product list.
Here you see the code of the listview button.
Step 2
Then create the following classes into a Java folder and add one layout in the layout section.
Layout Section
Step 3
Now add one method in MainActivity.Class because when the user clicks on the listview button then it moves on second activity and the name of the second activity is ListViewActivity.Class
Step 4
Now In Product. The class adds some attributes like product name, price, image, and description and then make a getter and setter methods of those attributes.
Step 5
In ProductDatasource.java class we make an arraylist because the benefit of arraylist is that it makes an array size at runtime and in arraylist we declare a loop because we show multiple items in the listview, not one, in this way we declare loop.
Why data source?
Items can add by
add () and remove by
remove ()
Step 6
Now in make ProductListActivity.java we declare a data source and connect with this class,