]> git.ktnx.net Git - mobile-ledger.git/commitdiff
dynamicaly add new table rows to the new transaction accounts list
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 30 Nov 2018 18:46:22 +0000 (18:46 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 30 Nov 2018 18:46:22 +0000 (18:46 +0000)
app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java
app/src/main/res/layout/content_new_transaction.xml

index 12e8b69eecdb4b98287999cb67f0351fa7205041..804f24961301addbc575fe5e0ed528ecd381667f 100644 (file)
@@ -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);
     }
 
 }
index c5170855e5f076d59ea06117db8f2858893e8839..4fcce131cd1299f5c45d6ffed58aed048df381d4 100644 (file)
@@ -28,6 +28,7 @@
                 android:textAlignment="center" />
 
             <TableLayout
+                android:id="@+id/new_transaction_accounts_table"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent">
 
                     <EditText
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_gravity="end"
                         android:layout_weight="1"
                         android:width="0dp"
-                        android:minWidth="36pt"
-                        android:ems="10"
-                        android:gravity="end"
                         android:hint="@string/new_transaction_amount_hint"
                         android:inputType="numberDecimal|numberSigned"
+                        android:minWidth="24pt"
                         android:textAlignment="viewEnd" />
                 </TableRow>
 
                     <EditText
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_gravity="end"
                         android:layout_weight="1"
                         android:width="0dp"
-                        android:minWidth="36pt"
-                        android:ems="10"
-                        android:gravity="end"
                         android:hint="@string/new_transaction_amount_hint"
                         android:inputType="numberDecimal|numberSigned"
+                        android:minWidth="24pt"
                         android:textAlignment="viewEnd" />
                 </TableRow>