From: Damyan Ivanov Date: Fri, 30 Nov 2018 18:46:22 +0000 (+0000) Subject: dynamicaly add new table rows to the new transaction accounts list X-Git-Tag: v0.3~370 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=664d47ee0e2d168af169b7f3b46ffefae2b3948f;p=mobile-ledger.git dynamicaly add new table rows to the new transaction accounts list --- diff --git a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java index 12e8b69e..804f2496 100644 --- a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java @@ -6,9 +6,14 @@ import android.support.design.widget.Snackbar; import android.support.v4.app.DialogFragment; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; +import android.text.InputType; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.widget.AutoCompleteTextView; +import android.widget.EditText; +import android.widget.TableLayout; +import android.widget.TableRow; import java.util.Objects; @@ -47,8 +52,25 @@ public class NewTransactionActivity extends AppCompatActivity { } public void addTransactionAccountFromMenu(MenuItem item) { - Snackbar.make(getCurrentFocus(), "Not implemented yet", Snackbar.LENGTH_LONG) - .setAction("Action", null).show(); + final AutoCompleteTextView acc = new AutoCompleteTextView(this); + acc.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 9f)); + acc.setHint(R.string.new_transaction_account_hint); + acc.setWidth(0); + + final EditText amt = new EditText(this); + amt.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 1f)); + amt.setHint(R.string.new_transaction_amount_hint); + amt.setWidth(0); + amt.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL ); + amt.setMinWidth(64); + amt.setTextAlignment(EditText.TEXT_ALIGNMENT_VIEW_END); + + final TableLayout table = findViewById(R.id.new_transaction_accounts_table); + final TableRow row = new TableRow(this); + row.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); + row.addView(acc); + row.addView(amt); + table.addView(row); } } diff --git a/app/src/main/res/layout/content_new_transaction.xml b/app/src/main/res/layout/content_new_transaction.xml index c5170855..4fcce131 100644 --- a/app/src/main/res/layout/content_new_transaction.xml +++ b/app/src/main/res/layout/content_new_transaction.xml @@ -28,6 +28,7 @@ android:textAlignment="center" /> @@ -45,14 +46,11 @@ @@ -70,14 +68,11 @@