Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void updateLastExpenses(){
- Cursor c = Expense.getAll(this);
- TableLayout lastExpensesTable = (TableLayout)findViewById(R.id.lastExpensesTable);
- lastExpensesTable.setStretchAllColumns(true);
- while (c.moveToNext()) {
- android.text.format.DateFormat df = new android.text.format.DateFormat();
- String name = c.getString(
- c.getColumnIndexOrThrow(ExpenseContract.ExpenseEntry.COLUMN_NAME_NAME)
- );
- float amount = c.getFloat(
- c.getColumnIndexOrThrow(ExpenseContract.ExpenseEntry.COLUMN_NAME_AMOUNT)
- );
- String date = c.getString(
- c.getColumnIndexOrThrow(ExpenseContract.ExpenseEntry.COLUMN_NAME_DATE)
- );
- TableRow tr = new TableRow(this);
- TextView c1 = new TextView(this);
- c1.setText(name);
- c1.setBackgroundColor(Color.RED);
- TextView c2 = new TextView(this);
- c2.setText(""+amount);
- c2.setBackgroundColor(Color.BLUE);
- tr.addView(c1);
- tr.addView(c2);
- lastExpensesTable.addView(tr);
- }
- }
- <TableLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/lastExpensesTable">
- <TableRow
- android:id="@+id/lastExpensesTableRow"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TextView
- android:id="@+id/lastExpensesTableName"
- android:text="@string/last_expenses_table_name"/>
- <TextView />
- <TextView
- android:id="@+id/lastExpensesTableAmount"
- android:text="@string/last_expenses_table_amount"/>
- <TextView />
- </TableRow>
- </TableLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement