Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `public class DisplayBills extends AppCompatActivity {
- public Button mAddBtn;
- private RecyclerView mRecyclerView;
- private CustomRecyclerAdapter mAdapter;
- private RecyclerView.LayoutManager mLayoutManager;
- private EditText mOrder;
- private EditText mDate;
- private EditText mName;
- private EditText mTdsin;
- private EditText mTdsout;
- private EditText mAmount;
- private List<Data> mData = new ArrayList<>();
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_display_bills);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- mAddBtn = (Button) findViewById(R.id.btn_add_bill);
- mAddBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- // Initializing views.
- mOrder = (EditText) findViewById(R.id.input_order_no);
- mDate = (EditText) findViewById(R.id.input_date);
- mName = (EditText) findViewById(R.id.input_c_name);
- mTdsin = (EditText) findViewById(R.id.input_tds_in);
- mTdsout = (EditText) findViewById(R.id.input_tds_out);
- mAmount = (EditText) findViewById(R.id.input_amount);
- mRecyclerView = (RecyclerView) findViewById(R.id.rv);
- // If the size of views will not change as the data changes.
- mRecyclerView.setHasFixedSize(true);
- // Setting the LayoutManager.
- mLayoutManager = new LinearLayoutManager(getApplicationContext());
- mRecyclerView.setLayoutManager(mLayoutManager);
- // Setting the adapter.
- mAdapter = new CustomRecyclerAdapter();
- mRecyclerView.setAdapter(mAdapter);
- }
- // Called when add button is clicked.
- public void addItem(View view) {
- // Add data locally to the list.
- Data dataToAdd = new Data(
- Integer.parseInt(mOrder.getText().toString()),
- Integer.parseInt(mDate.getText().toString()),
- mName.getText().toString(),
- Integer.parseInt(mTdsin.getText().toString()),
- Integer.parseInt(mTdsout.getText().toString()),
- Integer.parseInt(mAmount.getText().toString()));
- mData.add(dataToAdd);
- // Update adapter.
- mAdapter.addItem(mData.size() - 1, dataToAdd);
- }
- });
- FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
- fab.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(getApplicationContext(),
- AddNewBill.class);
- // Start DisplayBills Activity
- startActivity(intent);
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.display_bills, menu);
- return true;
- }
- `enter code here`<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <android.support.design.widget.AppBarLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- app:layout_scrollFlags="scroll|enterAlways"
- app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
- </android.support.design.widget.AppBarLayout>
- <android.support.v7.widget.RecyclerView
- android:id="@+id/rv"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- </android.support.v7.widget.RecyclerView>
- <android.support.design.widget.FloatingActionButton
- android:id="@+id/fab"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom|end"
- android:layout_margin="@dimen/fab_margin"
- android:src="@drawable/ic_add_white_24dp" />
- public class AddNewBill extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_add_new_bill);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- }
- <android.support.design.widget.CoordinatorLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <android.support.design.widget.AppBarLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- app:layout_scrollFlags="scroll|enterAlways"
- app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
- </android.support.design.widget.AppBarLayout>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:layout_marginTop="?attr/actionBarSize"
- android:orientation="vertical"
- android:paddingLeft="20dp"
- android:paddingRight="20dp"
- android:paddingTop="10dp">
- <android.support.design.widget.TextInputLayout
- android:id="@+id/order"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <EditText
- android:id="@+id/input_order_no"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="@string/hint_order"
- android:inputType="number"/>
- </android.support.design.widget.TextInputLayout>
- <android.support.design.widget.TextInputLayout
- android:id="@+id/date"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/order"
- android:layout_marginTop="4dp">
- <EditText
- android:id="@+id/input_date"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="@string/hint_date"
- android:inputType="date"/>
- </android.support.design.widget.TextInputLayout>
- <android.support.design.widget.TextInputLayout
- android:id="@+id/cusname"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/date"
- android:layout_marginTop="4dp">
- <EditText
- android:id="@+id/input_c_name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:hint="@string/hint_cname" />
- </android.support.design.widget.TextInputLayout>
- <android.support.design.widget.TextInputLayout
- android:id="@+id/tin"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/cusname"
- android:layout_marginTop="4dp">
- <EditText
- android:id="@+id/input_tds_in"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="number"
- android:hint="@string/hint_tdsin" />
- </android.support.design.widget.TextInputLayout>
- <android.support.design.widget.TextInputLayout
- android:id="@+id/tout"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/tin"
- android:layout_marginTop="4dp">
- <EditText
- android:id="@+id/input_tds_out"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="number"
- android:hint="@string/hint_tdsout" />
- </android.support.design.widget.TextInputLayout>
- <android.support.design.widget.TextInputLayout
- android:id="@+id/tamount"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/tout"
- android:layout_marginTop="4dp">
- <EditText
- android:id="@+id/input_amount"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="number"
- android:hint="@string/hint_amount" />
- </android.support.design.widget.TextInputLayout>
- <Button android:id="@+id/btn_add_bill"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/btn_add_bill"
- android:background="@color/colorPrimary"
- android:layout_marginTop="40dp"
- android:textColor="@android:color/white"/>
- </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement