Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

adding row

$
0
0

as you can see in the photo, i have a row, add row button and save button.
is there a way where i can add rows? the row above is made of separate edit texts that i put in a table layout.
i was thinking of doing it like i have a set of rows already, then i'll hide the 2nd to the last row, then when i click
the "add row" button the 2nd row will appear and so on. is that possible? or is there an automatic way of adding rows?
thank you.

this is the axml code for the rows.

<TableLayout
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="178.4dp"
    android:id="@+id/tableLayout1">
    <TableRow
        android:id="@+id/tableRow4">
        <EditText
            android:layout_column="0"
            android:id="@+id/ActionNum"
            android:background="@android:color/background_light"
            android:textColor="#ff000000"
            android:layout_width="61.3dp"
            android:layout_marginRight="3dp"
            android:layout_marginLeft="3dp"
            android:editable="false" />
        <EditText
            android:layout_column="1"
            android:id="@+id/NameText"
            android:background="@android:color/background_light"
            android:layout_marginRight="3dp"
            android:textColor="#ff000000"
            android:layout_width="148.6dp" />
        <EditText
            android:layout_column="2"
            android:id="@+id/NotesText"
            android:layout_width="271.4dp"
            android:background="@android:color/background_light"
            android:layout_marginRight="3dp"
            android:textColor="#ff000000" />
        <EditText
            android:layout_column="3"
            android:id="@+id/ByWhenText"
            android:background="@android:color/background_light"
            android:layout_marginRight="3dp"
            android:textColor="#ff000000"
            android:layout_width="48.5dp" />
        <Button
            android:layout_column="4"
            android:id="@+id/CalendarBtn"
            android:background="@android:drawable/ic_menu_my_calendar"
            android:layout_width="31.8dp"
            android:layout_height="34.5dp" />
        <AutoCompleteTextView
            android:layout_column="5"
            android:id="@+id/AddFieldText"
            android:background="@android:color/background_light"
            android:textColor="#ff000000"
            android:layout_width="51.5dp" />
    </TableRow>

and this is the code how i save from the row.

// set our layout to be the home screen
        SetContentView(Resource.Layout.ProjectDetails);
        nameTextEdit = FindViewById<EditText>(Resource.Id.NameText);
        notesTextEdit = FindViewById<EditText>(Resource.Id.NotesText);
        ActionNumTextEdit = FindViewById<EditText> (Resource.Id.ActionNum);
        ByWhenTextEdit = FindViewById<EditText> (Resource.Id.ByWhenText);
        AddFieldTextEdit = FindViewById<EditText> (Resource.Id.AddFieldText);
        ProjectNameTextEdit = FindViewById<EditText> (Resource.Id.ProjectNameText);
        saveButton = FindViewById<Button>(Resource.Id.SaveButton);
        calendarButton = FindViewById <Button> (Resource.Id.CalendarBtn);



        // find all our controls    

        //CheckBox Wire
        //doneCheckbox = FindViewById<CheckBox>(Resource.Id.chkDone);
        //doneCheckbox.Checked = task.Done;

        // set the cancel delete based on whether or not it's an existing task



        string text = Intent.GetStringExtra ("FirstActivity") ?? "";
        ByWhenTextEdit.Text = text;


        nameTextEdit.Text = task.Name; 
        notesTextEdit.Text = task.Notes;
        ActionNumTextEdit.Text = task.ActionNum;
        AddFieldTextEdit.Text = task.AddField;
        ProjectNameTextEdit.Text = task.ProjectName;


        calendarButton.Click += (sender,  e) => {
            StartActivity (typeof(CalendarDemoActivity));
            };

        // button clicks 
        //cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
        saveButton.Click += (sender, e) => { Save(); };
    }

    void Save()
    {
        task.Name = nameTextEdit.Text;
        task.Notes = notesTextEdit.Text;
        task.ByWhen = ByWhenTextEdit.Text;
        task.ActionNum = ActionNumTextEdit.Text;
        task.ProjectName = ProjectNameTextEdit.Text;
        task.AddField = AddFieldTextEdit.Text;
        TaskManager.SaveTask(task);
        Finish();
    }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>