7. Creating Android Application
Create a new project in your Eclipse IDE by filling the required details.
1. Create new project in Eclipse IDE by going to File ⇒ New ⇒ Android Project and name the Activity class name as MainScreenActivity.
2. Open your AndroidManifest.xml file and add following code. First i am adding all the classes i am creating to manifest file. Also i am adding INTERNET Connect permission.
3. Now create a new xml file under res ⇒ layout folder and name it as main_screen.xmlThis layout file contains two simple buttons to view all products and add a new product.
4. Open you main activity class which is MainScreenActivity.java and write click events for two button which are mentioned in main_screen.xml layout.
Displaying All Products in ListView (Read)
5. Now we need an Activity display all the products in list view format. As we know list view needs two xml files, one for listview and other is for single list row. Create two xml files under res ⇒ layout folder and name it as all_products.xml and list_item.xml
6. Create a new class file and name it as AllProductsActivity.java. In the following code
-> First a request is send to get_all_products.php file using a Background Async task thread.
-> After getting JSON from get_all_products.php, i parsed it and displayed in a listview.
-> If there are no products found AddNewProductAcivity is launched.