Create Inventory Ecommerce Application Android Studio

Create Inventory Ecommerce Application Android Studio – In this tutorial i will show how to develop Inventory E-Commerce application in android studio. Now a days this is trend of develop e-commerce android application because everyone used to buy products on e-commerce websites like Flipkart, Amazon and more shopping application.

Most of business peoples are now migrate into online software. Because it has lot of features, easy to use, backup files, fastest response and more. This is the major reason for why everyone migrate into online inventory software for their business purpose.

Nowadays we have more options to make money via developing android applications. So here I recommend one of the popular article for you to make cash from trusted website. Earn $5 per Day when you get profitable clients for your projects.

So all of students and developers like to develop the same of e-commerce android studio application like flipkart using Java. That’s why here i have create simple android inventory ecommerce application, no UI developed just we develop the concept of buy the product. If you want to add the UI designs just modify the Java classes and XML files to get perfect user interface designs.

Create Inventory Ecommerce Application Android

Let’s start to create Android Inventory Ecommerce application in android studio. First Create new project and choose Empty Activity file. After creating the project just open the default class of MainActivity.java class file and add the following codes. It’s not a hard part in e-commerce sector, within a weeks you can completely learn the complicated things.

MainActivity.java

package com.example.android.stockkeepingassistant.view.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;

import com.example.android.stockkeepingassistant.R;

import java.util.UUID;

public class ProductActivity extends AppCompatActivity {
    private static final String EXTRA_PRODUCT_ID = "com.example.android.stockkeepingassistant.product_id";

    public static Intent newIntent(Context packageContext, UUID productId) {
        Intent intent = new Intent(packageContext, ProductActivity.class);
        intent.putExtra(EXTRA_PRODUCT_ID, productId);
        return intent;
    }
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product);
        getSupportActionBar().setTitle(R.string.product_fragment_title);

        UUID productId = (UUID) getIntent().getSerializableExtra(EXTRA_PRODUCT_ID);

        FragmentManager fm = getSupportFragmentManager();
        Fragment fragment = fm.findFragmentById(R.id.fragment_container);

        if (fragment == null) {
            fm.beginTransaction()
                    .add(R.id.fragment_container, ProductFragment.newInstance(productId))
                    .commit();
        }
    }
}

After that create another class for add the product list. Give some name for that class and add the below code and here this is not a simple project we need more java classes to make inventory ecommerce application so finally i have give full source code because not enough space to explain.

Product.java

package com.example.android.stockkeepingassistant.model;

import android.support.annotation.Nullable;

import java.math.BigDecimal;
import java.util.UUID;

public class Product {
    /* Class variables */
    private UUID id;
    private String title;
    private int quantity;
    private BigDecimal price;
    private String supplierName;
    private String supplierEmail;

    public Product() {
        this(UUID.randomUUID());
    }

    public Product(UUID id) {
       this.id = id;
       quantity = 1;

       // Detour to rounding up to 2 decimal places
       BigDecimal init = new BigDecimal(0);
       price = init.setScale(2, BigDecimal.ROUND_HALF_UP);
    }

    public UUID getId() {
        return id;
    }

    public String getPhotoFilename() {
        return "IMG_" + getId().toString() + ".jpg";
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    @SuppressWarnings("UnnecessaryLocalVariable")
    public BigDecimal getPrice() {
        // Create local var to format to 2 decimal places
        BigDecimal formattedPrice = price.setScale(2, BigDecimal.ROUND_HALF_UP);
        return formattedPrice;
    }

    public void setPrice(BigDecimal price) {
        if (price.compareTo(BigDecimal.ZERO) == 0) {
            return; // Bail if user has not changed default value
        }
        // Record only up to 2 decimal places
        this.price = price.setScale(2, BigDecimal.ROUND_HALF_UP);
    }

    @Nullable
    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public String getSupplierEmail() {
        return supplierEmail;
    }

    public void setSupplierEmail(String supplierEmail) {
        this.supplierEmail = supplierEmail;
    }
}

Activity Layouts

Now time to integrate java class files with XML layouts. Open under the path of res =>layout =>activity_main.xml file and add the following code,

<?xml version="1.0" encoding="utf-8"?><!-- Layout for list of products -->
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="@dimen/normal_margin"
    tools:context=".view.ui.CatalogActivity">

    <!-- List of products -->
    <android.support.v7.widget.RecyclerView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical" />

    <!-- Empty view for the list -->
    <TextView
        android:id="@+id/empty_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="@string/user_instructions"
        android:textAppearance="?android:textAppearanceMedium"
        android:visibility="gone" />

    <!-- New product addition button -->
    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_margin="@dimen/medium_margin"
        android:src="@drawable/ic_add" />

</RelativeLayout>

Download Source Code

I hope above explanation and source code helps to build online inventory management system project in android studio. Here you can download the source code in free of cost and we provide lot projects code in various program. For example we have PHP, Python, C Sharp, Java and more source code available.

Android Inventory Ecommerce application

Leave a Reply