I need to add the imageview at the right side of table row that is generated dynamically..
I have added imageviews to table rows.. How to add images at right i.e. set gravity to right.
Can anyone help me over this?
Thanks
You have to create a XML file for table row and Using LayoutInflater you can get a view from that XML file.
You have to study about Layout Inflater
Related
I am looking for solution where could dispay large data with horizontal and vetical scroll. Something like this https://www.syncfusion.com/blogs/post/new-datagrid-for-xamarinios-and-xamarinandroid.aspx. I would like to change number of columns and change the cell values.
Do you have please something like this? When it be a free i will be really happy. Thank you
You can create it by custom TableLayout. And the good news is you can add both side scrolling mechanism in TableLayout. You have to first set a TableLayout xml. For both side scrolling you have to add first ScrollView then HorizontalScrlollView then your TableLayout.
Now you you can create row and column. You can create it dynamically because you (may be) dont know how many column has required. So you have to create custom TableRow and cell and you can easily add your tableLayout .
TableRow row= new TableRow(this);
TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
row.setLayoutParams(lp);
// then create your text view and add it row. and last add row in your table layout
This is just example. You can create your own data grid library
And you can some ready mate library to show data grid in table view like your reference. :
https://github.com/evrencoskun/TableView
https://github.com/ISchwarz23/SortableTableView
In my app I have a fragment uses tablelayout. I define the header of my table in the XML and I add the table rows when I instantiate the fragment. Using data from my database.
When I add a table row the width is not equal of the first table row ( the header ).
How can I define the same width for all rows? I have to define a constant width?
To solve my problem I created a separate xml that represents the lines in my layout. So, in my TableLayout I add a line using include tag for the header. And the rest of the lines I create during runtime.
Useful link: http://developer.android.com/training/improving-layouts/reusing-layouts.html
I want to use a GridView to display data that is separated alphabetically by row. Each row of the grid view should contain up to four names, and there should only be names starting with the same letter in a row. I know how to set up a GridView, just not how to set it up in this format. The screenshot below shows what I would like to do:
Make a layout file table.xml for the Grid or TableLayout. Make a layout file cell.xml for the cell. Now order names and put them into appropriate cells by inflating the cell.xml.
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
...
view = inflater.inflate(R.layout.cell, table, false);
tableRow.addChild(view);
view.setText(name);
I think, you'll manage table rows creation by yourself.
The simpliest way is to make static layout e.g. Linear oriented vertically with internal 26 grids (or just put grids in runtime)
-Scroll
----Linaear(vertical)
-------GridView(id=aGrid, w=match_parent, h=wrap_content)
-------GridView(id=bGrid, w=match_parent, h=wrap_content)
...
-------GridView(id=zGrid, w=match_parent, h=wrap_content)
Then, to bind data with UI you can declare Map gridViews and push data accordingly word's first letter.
Hiiii there, I have an xml layout and when a button is clicked I need to add a TableLayout view to that xml layout. I know how to do this with simple stuff like text views but tables would seem to be a lot harder to define programmatically, Im not quite sure what inflating is but is that what I should be using? Thanks.
You can define the layout in an xml file and then simply inflate that layout using the LayoutInflater. This will give you a View (in your case this will be a TableLayout), then add this view and you are done.
Reference: LayoutInflater
In your xml layout, let's say you want to add the TableLayout inside a RelativeLayout with an id of relativeLayout1.
To add it, you would do the following code:
TableLayout table = new TableLAyout();
// Code to add rows and views to the table
R.findViewById("relativeLayout1").add(table);
Iam trying to create a table with borders using TableLayout. If I add static rows in xml file i am able to see the borders. But the problem arises if I try to add some dynamic rows. Data for the table comes dynamically. Can anyone help in solving this problem. If possible please provide the source code(.java file and .xml file).
You can create a rectangle image to use as a background for the row. TableRow extends View, so this should work (untested).
TableRow row = new TableRow (this);
row.setBackgroundResource (android.R.drawable.edit_text);
// rest of your code
If it doesn't work, the (tested) solution is to add a color background to the table and padding to the row.