Advertisement
Guest User

Untitled

a guest
Dec 24th, 2015
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.15 KB | None | 0 0
  1. `public class DisplayBills extends AppCompatActivity {
  2.  
  3.  
  4. public Button mAddBtn;
  5. private RecyclerView mRecyclerView;
  6. private CustomRecyclerAdapter mAdapter;
  7. private RecyclerView.LayoutManager mLayoutManager;
  8.  
  9. private EditText mOrder;
  10. private EditText mDate;
  11. private EditText mName;
  12. private EditText mTdsin;
  13. private EditText mTdsout;
  14. private EditText mAmount;
  15.  
  16. private List<Data> mData = new ArrayList<>();
  17.  
  18. @Override
  19. protected void onCreate(Bundle savedInstanceState) {
  20. super.onCreate(savedInstanceState);
  21. setContentView(R.layout.activity_display_bills);
  22. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  23. setSupportActionBar(toolbar);
  24.  
  25. mAddBtn = (Button) findViewById(R.id.btn_add_bill);
  26.  
  27. mAddBtn.setOnClickListener(new View.OnClickListener() {
  28. @Override
  29. public void onClick(View view) {
  30. // Initializing views.
  31. mOrder = (EditText) findViewById(R.id.input_order_no);
  32. mDate = (EditText) findViewById(R.id.input_date);
  33. mName = (EditText) findViewById(R.id.input_c_name);
  34. mTdsin = (EditText) findViewById(R.id.input_tds_in);
  35. mTdsout = (EditText) findViewById(R.id.input_tds_out);
  36. mAmount = (EditText) findViewById(R.id.input_amount);
  37. mRecyclerView = (RecyclerView) findViewById(R.id.rv);
  38.  
  39. // If the size of views will not change as the data changes.
  40. mRecyclerView.setHasFixedSize(true);
  41.  
  42. // Setting the LayoutManager.
  43. mLayoutManager = new LinearLayoutManager(getApplicationContext());
  44. mRecyclerView.setLayoutManager(mLayoutManager);
  45.  
  46. // Setting the adapter.
  47. mAdapter = new CustomRecyclerAdapter();
  48. mRecyclerView.setAdapter(mAdapter);
  49. }
  50.  
  51. // Called when add button is clicked.
  52. public void addItem(View view) {
  53.  
  54. // Add data locally to the list.
  55. Data dataToAdd = new Data(
  56. Integer.parseInt(mOrder.getText().toString()),
  57. Integer.parseInt(mDate.getText().toString()),
  58. mName.getText().toString(),
  59. Integer.parseInt(mTdsin.getText().toString()),
  60. Integer.parseInt(mTdsout.getText().toString()),
  61. Integer.parseInt(mAmount.getText().toString()));
  62. mData.add(dataToAdd);
  63.  
  64. // Update adapter.
  65. mAdapter.addItem(mData.size() - 1, dataToAdd);
  66. }
  67. });
  68.  
  69.  
  70. FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  71. fab.setOnClickListener(new View.OnClickListener() {
  72. @Override
  73. public void onClick(View view) {
  74. Intent intent = new Intent(getApplicationContext(),
  75. AddNewBill.class);
  76.  
  77. // Start DisplayBills Activity
  78. startActivity(intent);
  79. }
  80. });
  81.  
  82. }
  83.  
  84. @Override
  85. public boolean onCreateOptionsMenu(Menu menu) {
  86. // Inflate the menu; this adds items to the action bar if it is present.
  87. getMenuInflater().inflate(R.menu.display_bills, menu);
  88. return true;
  89. }
  90.  
  91. `enter code here`<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
  92. xmlns:app="http://schemas.android.com/apk/res-auto"
  93. android:layout_width="match_parent"
  94. android:layout_height="match_parent">
  95.  
  96. <android.support.design.widget.AppBarLayout
  97. android:layout_width="match_parent"
  98. android:layout_height="wrap_content"
  99. android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
  100.  
  101. <android.support.v7.widget.Toolbar
  102. android:id="@+id/toolbar"
  103. android:layout_width="match_parent"
  104. android:layout_height="?attr/actionBarSize"
  105. android:background="?attr/colorPrimary"
  106. app:layout_scrollFlags="scroll|enterAlways"
  107. app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
  108. </android.support.design.widget.AppBarLayout>
  109.  
  110. <android.support.v7.widget.RecyclerView
  111. android:id="@+id/rv"
  112. android:layout_width="match_parent"
  113. android:layout_height="match_parent">
  114. </android.support.v7.widget.RecyclerView>
  115.  
  116. <android.support.design.widget.FloatingActionButton
  117. android:id="@+id/fab"
  118. android:layout_width="wrap_content"
  119. android:layout_height="wrap_content"
  120. android:layout_gravity="bottom|end"
  121. android:layout_margin="@dimen/fab_margin"
  122. android:src="@drawable/ic_add_white_24dp" />
  123.  
  124. public class AddNewBill extends AppCompatActivity {
  125. @Override
  126. protected void onCreate(Bundle savedInstanceState) {
  127. super.onCreate(savedInstanceState);
  128. setContentView(R.layout.activity_add_new_bill);
  129. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  130. setSupportActionBar(toolbar);
  131.  
  132. }
  133.  
  134. <android.support.design.widget.CoordinatorLayout
  135. xmlns:android="http://schemas.android.com/apk/res/android"
  136. xmlns:app="http://schemas.android.com/apk/res-auto"
  137. android:layout_width="match_parent"
  138. android:layout_height="match_parent">
  139.  
  140. <android.support.design.widget.AppBarLayout
  141. android:layout_width="match_parent"
  142. android:layout_height="wrap_content"
  143. android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
  144.  
  145. <android.support.v7.widget.Toolbar
  146. android:id="@+id/toolbar"
  147. android:layout_width="match_parent"
  148. android:layout_height="?attr/actionBarSize"
  149. android:background="?attr/colorPrimary"
  150. app:layout_scrollFlags="scroll|enterAlways"
  151. app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
  152. </android.support.design.widget.AppBarLayout>
  153.  
  154. <LinearLayout
  155. android:layout_width="fill_parent"
  156. android:layout_height="match_parent"
  157. android:layout_marginTop="?attr/actionBarSize"
  158. android:orientation="vertical"
  159. android:paddingLeft="20dp"
  160. android:paddingRight="20dp"
  161. android:paddingTop="10dp">
  162.  
  163. <android.support.design.widget.TextInputLayout
  164. android:id="@+id/order"
  165. android:layout_width="match_parent"
  166. android:layout_height="wrap_content">
  167.  
  168. <EditText
  169. android:id="@+id/input_order_no"
  170. android:layout_width="match_parent"
  171. android:layout_height="wrap_content"
  172. android:hint="@string/hint_order"
  173. android:inputType="number"/>
  174. </android.support.design.widget.TextInputLayout>
  175.  
  176. <android.support.design.widget.TextInputLayout
  177. android:id="@+id/date"
  178. android:layout_width="match_parent"
  179. android:layout_height="wrap_content"
  180. android:layout_below="@id/order"
  181. android:layout_marginTop="4dp">
  182.  
  183. <EditText
  184. android:id="@+id/input_date"
  185. android:layout_width="match_parent"
  186. android:layout_height="wrap_content"
  187. android:hint="@string/hint_date"
  188. android:inputType="date"/>
  189. </android.support.design.widget.TextInputLayout>
  190.  
  191. <android.support.design.widget.TextInputLayout
  192. android:id="@+id/cusname"
  193. android:layout_width="match_parent"
  194. android:layout_height="wrap_content"
  195. android:layout_below="@id/date"
  196. android:layout_marginTop="4dp">
  197.  
  198. <EditText
  199. android:id="@+id/input_c_name"
  200. android:layout_width="match_parent"
  201. android:layout_height="wrap_content"
  202. android:hint="@string/hint_cname" />
  203. </android.support.design.widget.TextInputLayout>
  204.  
  205. <android.support.design.widget.TextInputLayout
  206. android:id="@+id/tin"
  207. android:layout_width="match_parent"
  208. android:layout_height="wrap_content"
  209. android:layout_below="@id/cusname"
  210. android:layout_marginTop="4dp">
  211.  
  212. <EditText
  213. android:id="@+id/input_tds_in"
  214. android:layout_width="match_parent"
  215. android:layout_height="wrap_content"
  216. android:inputType="number"
  217. android:hint="@string/hint_tdsin" />
  218. </android.support.design.widget.TextInputLayout>
  219.  
  220. <android.support.design.widget.TextInputLayout
  221. android:id="@+id/tout"
  222. android:layout_width="match_parent"
  223. android:layout_height="wrap_content"
  224. android:layout_below="@id/tin"
  225. android:layout_marginTop="4dp">
  226.  
  227. <EditText
  228. android:id="@+id/input_tds_out"
  229. android:layout_width="match_parent"
  230. android:layout_height="wrap_content"
  231. android:inputType="number"
  232. android:hint="@string/hint_tdsout" />
  233. </android.support.design.widget.TextInputLayout>
  234.  
  235. <android.support.design.widget.TextInputLayout
  236. android:id="@+id/tamount"
  237. android:layout_width="match_parent"
  238. android:layout_height="wrap_content"
  239. android:layout_below="@id/tout"
  240. android:layout_marginTop="4dp">
  241.  
  242. <EditText
  243. android:id="@+id/input_amount"
  244. android:layout_width="match_parent"
  245. android:layout_height="wrap_content"
  246. android:inputType="number"
  247. android:hint="@string/hint_amount" />
  248. </android.support.design.widget.TextInputLayout>
  249.  
  250. <Button android:id="@+id/btn_add_bill"
  251. android:layout_width="fill_parent"
  252. android:layout_height="wrap_content"
  253. android:text="@string/btn_add_bill"
  254. android:background="@color/colorPrimary"
  255. android:layout_marginTop="40dp"
  256. android:textColor="@android:color/white"/>
  257.  
  258. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement