Add one more row - android-layout

I am Android developer .While clicking plus button i need one more row.
For Ex (Edit contacts We are click plus means added one more row and minus means remove that row.Just give me xml layout and sample coding for me.)

Create an onClickListener() for the button. Then reference your tableLayout via
tblLayout = (TableLayout)findViewById(R.id.tableLayout);
then use
TableRow = new TableRow(this);
//Do something with this row
row.setText("...");
//add the row to the tblLayout
tblLayout.addView(row);

Related

Disabling button in a specific row of a C1TrueDBGrid

I am using c1truedbgrid. I have columns added in the grid with one column having button which is displayed is every row. I need to disable the button in a particular row depending on some business logic. How this can be done?
I am not sure why there aren't any answer.
Its fairly simple. Lets say I want to disable the buttons from those rows where ID is even.
for(int i = 0; i< c1truedbgridobject.Splits[0].Rows.Count; i++)
{
if(Convert.ToInt32(c1truedbgridobject[i,1].ToString())%2 == 0)
{
//Disable here
}
}
However the disable part is dependent on how you are adding button to a cell. Since add button is referenced to whole column and not to a particular cell.
Anyhow using a OwnerDrawCell is also an option.
EDIT:
This seems as a limitation of C1TrueDBGrid. You may use C1FlexGrid as an alternative.
You need to make property of that column as "locked=True" as Below example when you initializing grid.
C1TrueDbGridName.Splits(0).DisplayColumns("YourColumnNameHavingButton").Locked = True
it will make your row not to be editable

Export right-to-left from RadGridView

I have a Silverlight application which has a RadGridView that is right to left.
when I export the grid, the result is left to right table.
I want the exported table would be in right to left format
(for example in Excel the sheet would be in right to left direction)
Edit not from OP to transfer clarification provided in comment
This picture is from the export result:
and this one is when I change sheet direction manually:
By adding some styling at the header part of your output in the export function, and for the Right-to-left alignment option it's inserted at the <WorksheetOptions> level of the declaration which called <x:DisplayRightToLeft/>.
Example if you're using C# in your project:
private string AddExcelStyling()
{
StringBuilder sb = new StringBuilder();
sb.Append("<html xmlns:o='urn:schemas-microsoft-com:office:office'\n" +
"xmlns:x='urn:schemas-microsoft-com:office:excel'\n" +
"xmlns='http://www.w3.org/TR/REC-html40'>\n" +
"<head>\n");
sb.Append("<style>\n");
sb.Append("#page");
sb.Append("mso-page-orientation:landscape;}\n");
sb.Append("</style>\n");
sb.Append("<!--[if gte mso 9]><xml>\n");
sb.Append("<x:ExcelWorkbook>\n");
sb.Append("<x:ExcelWorksheets>\n");
sb.Append("<x:ExcelWorksheet>\n");
sb.Append("<x:Name>Sheet Name</x:Name>\n");
sb.Append("<x:WorksheetOptions>\n");
sb.Append("<x:Print>\n");
sb.Append("<x:HorizontalResolution>600</x:HorizontalResolution\n");
sb.Append("<x:VerticalResolution>600</x:VerticalResolution\n");
sb.Append("</x:Print>\n");
sb.Append("<x:Selected/>\n");
sb.Append("<x:DisplayRightToLeft/>\n");
sb.Append("<x:DoNotDisplayGridlines/>\n");
sb.Append("</x:WorksheetOptions>\n");
sb.Append("</x:ExcelWorksheet>\n");
sb.Append("</x:ExcelWorksheets>\n");
sb.Append("</x:ExcelWorkbook>\n");
sb.Append("</xml><![endif]-->\n");
sb.Append("</head>\n");
sb.Append("<body>\n");
return sb.ToString();
}
See this link: http://forums.asp.net/p/1445619/3358464.aspx
I still have next to no idea of what is required, but here are some possibilities:
Starting with this:
sort ABC columns: Row / Sort by Row 1; Sort On Values; Order Largest to Smallest to get:
then click on Right-to-Left icon to get:
and sort again (same selection) to get this:
Stop when desired result is achieved.
Delete Row 1.
For code version click on Record Macro and repeat as many of above steps as required.
Stop recording.

JavaFX2.2 TableView:How to make a table cell be edited without mouse click?

I've encounter a problem with editable table cells. I'm using the TableView in my project just as the Tutorial on Oracle.
According to it, I use the setCellFactory method to reimplement the table cell as a text field with the help of the TextFieldTableCell class. However, I found the steps is a little complex to get to the point where the cell can be edited:
Let the table cell be selected by using direction key.
Press “Enter” to converts the cell to a text filed so that it is ready to be edited.
Clicking in the text field allows the contents to be edited
The problem is step 3, that you must use the mouse to click before you can input data in this table cell.
So, is there a solution to avoid step 3? That is the text field allows the data inputting when you just press “Enter”(step 2).
By the way, English is not my native language. Hope I have made myself clear.
The Node can be focused manually. The TextFieldTableCell is a TableCell that has a Node (Graphic) TextField which will be rendered when the cell is in editing mode. You need to focus to this textField manually but by using TextFieldTableCell you cannot access to the textField. However if you would prefer the alternative way described in the tutorial you are referring, then you have a chance to focus. The only changed method from that tutorial is:
#Override
public void startEdit() {
super.startEdit();
createTextField();
setText(null);
setGraphic(textField);
textField.selectAll();
// Set the focus
Platform.runLater(new Runnable() {
#Override
public void run() {
textField.requestFocus();
}
});
}
To start editing in a TableView without mouse-click event, invoke TreeView.edit(rowIndex, tableColumn);
For example:
//create tableview object
TableView<YourModel> tableView = new TableView<>();
//create column
TableColumn<YourModel, String> column = new TableColumn<>("Property Name");
//add column to tableview
tableView.getColumns().add(column);
//... your cell factory and the rest
//add an item
tableView.getItems().add(new YourModel());
//if you want to edit the selected item, get its index
int selectedIndex = tableView.getSelectionModel().getSelectedIndex();
//fire edit
tableView.edit(selectedIndex, column);

How to put 4 button in row use lwuit? At the same distance

how to put 4 button in row, as in the picture:
The distance between the elements should be changed at different resolutions
There are allot of ways to do everything in LWUIT. Its unclear from your image what your exact constraints are, I'm guessing you want the left most button to be left aligned and the right most to be right aligned. You probably also want the two other buttons to be centered.
I would implement this using a GridLayout with nested FlowLayout elements. As such:
Container c = new Container(new GridLayout(1, 4));
addButton(c, new Button("b1"), Component.LEFT);
addButton(c, new Button("b2"), Component.CENTER);
addButton(c, new Button("b3"), Component.CENTER);
addButton(c, new Button("b4"), Component.RIGHT);
private void addButton(Container c, Button b, int align) {
Container flow = new Container(new FlowLayout(align));
flow.addComponent(b);
c.addComponent(flow);
}
Play with setMargin(Component.RIGHT,x) for the first three Buttons. Set the value of x such that the Buttons are equi-partitioned in the row : you must take into account the preferredWidth of the Buttons for that. For the first Button set its margin-left to 0 ( setMargin(Component.LEFT,0) ) , and for the last Button set its right-margin to 0 ( setMargin(Component.RIGHT,0) ).
You should use use BorderLayout and add the container (described in this answer inside south)

C# TableLayoutPanel replace control?

I was wondering if it was possible to replace one control in a TableLayoutPanel with another at runtime. I have a combo box and a button which are dynamically added to the TableLayoutPanel at runtime, and when the user selects an item in the combo box and hits the button, I'd like to replace the combobox with a label containing the text of the selected combo box item.
Basically, if I could simply remove the control and insert another at it's index, that would work for me. However I don't see an option like "splice" or "insert" on the Controls collection of the TableLayoutPanel, and I was wondering if there was a simple way to insert a control at a specific index. Thanks in advance.
Fixed this by populating a panel with the two controls I wanted to swap and putting that into the TableLayoutPanel. Then I set their visibility according to which I wanted to see at what time.
This is what I've been able to come up with for what I needed. It gets the position of the ComboBox and makes a new label using the selected value.
// Replaces a drop down menu with a label of the same value
private void lockDropMenu(ComboBox dropControl)
{
TableLayoutPanelCellPosition pos = myTable.GetCellPosition(dropControl);
Label lblValue = new Label();
myTable.Controls.Remove(dropControl);
if (dropControl.SelectedItem != null)
{
lblValue.Text = dropControl.SelectedItem.ToString();
lblValue.Font = lblValue.Font = dropControl.Font;
// Just my preferred formatting
lblValue.AutoSize = true;
lblValue.Dock = System.Windows.Forms.DockStyle.Fill;
lblValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
myTable.Controls.Add(lblValue, pos.Column, pos.Row);
}
}

Resources