Listview vs TableView in Android Studio - java

I need to recreate this table in my app: https://imgur.com/a/1HtpFqO
The third field must be editable by the user, so I don't know if I should prefer ListView for this reason. What do you think?
Also, do you know if are there existing library to create this exactly design?

That depends whether your table holds data that will change or you will always have the same table with editable third field. If you have static data you don't really need to have a list.
If you have data that changes, RecyclerView is your go to option. Create it with different ViewHolder types, one type for non-editable fields and the other for editable field.
Also, there is no need to add 3rd party library just to achieve this simple table.

You can use Recyclerview with different views Like this and this

Related

Best way to do a timetable in Android?

I'm trying to decide on the best way to display a timetable to the user.
Ideally I wanted the data to be displayed in a table layout but I quickly realized that each table row required like 18 text views for the relevant data.
I've checked a calendar component, no use. A table layout does seem the best way to go but what's the best way to implement it so that it's easy to get data from my DB and read it into the table?
You can use GridView with its adapter:
https://developer.android.com/guide/topics/ui/layout/gridview.html

How I can build table in onpostexecute() in Android?

I need to build a table with 1 column and many rows, I am getting data from a server, and then I want to populate this data into the table.
In iOS I can use UITableVIew. As I understand, I need to create gridLayout on builder and then I need to find it by id in the method onCreate. Then I need to pass this object to my Asyncr class, then I need to get data and build table in the method onpostexecute.
Which of the methods I need to use? I want to do simple table like this (but example on iOS) without headers with date
Also i need to do clickable row, if you click on row i need to send you on other activity
Any ideas ?
You can use custom ListView
In onPostExecute(Object obj) parse your data, and set the adapter.

How to make a table refresh in an Eclipse plugin?

I have developed an Eclipse plugin, when I clicked the button a table appears on the view. However, this table does not refresh itself, when I click it again or when I a run operations on the table (such as deletion).
While I was implementing my table, I used TableColumn to create my columns and "TableItem" for the rows and values. Therefore, the "TableViewer"s refresh or remove functions does not work.
My table is able to appear, when I click the button and I call this function in the handler, such as;
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView("ViewID");
However, still I am not able refresh it. Any help would be nice.
Thanks!
Basically, you need to call viewer.update() whenever you want to refresh or update the table. SWT tables and JFace viewers does not have a way to monitor the data model.
Alternatively, you can use Eclipse Data Binding to bind the model and the controls/viewers together. Have a look at this entry level tutorial to get you started.

Create a properties frame in Java

I am trying to make a properties frame just like the one in netBeans (or Visual Studio). My problem is that I don't know exactly how to design it. First I thought I'll make it with JTable (2 columns, multiple rows) but then I realised that on the second column I will have different types of values (booleans, String, color choosers, etc.), but I think that JTable allows only 1 type of data to be placed in a column.
I would like someone to tell me "JTable allows multiple data types on the same column" and show me how to do it, or tell me a different approach to the problem.
You can perfectly tell a JTable to have a column that contains Object, this way you will be able to put whatever ou want in.
BUT.
You'll then have to implement a very good TableCellRenderer/TableCellEditor pair in order to display whatever the cell contains.
Another option would be to use a Grid or GridBag layout inside of a JScrollPane, then dynamically populate the cells of the grid with different editors depending on the data type of the property.
If you can use external libraries, the JGoodies FormLayout is really suited to create such dialogs. Just take a look at the screenshots in their demo.
There is also a rather good PDF available containing with some examples and explanations.

Question about creating GUIS "dynamically" on Android

I'm trying to make an android app (I'm new in the Android programming world), and I'm having problems creating the GUI.
The point is that I get information of some data that is divided in days... The problem is that I don't know, until I retrieve the information, how many days the GUI should display.
http://img574.imageshack.us/img574/3787/mainscreen.jpg
The grey part will be a TextView, and, also, the black part will be another TextView with multiple lines.
So, the point is, how can I do to have multiple TextView's without knowing before the exact number? I suppose that I can't declare them in the layout.xml
The only solution that I've been thinking about is to create in the layout 7 pairs of TextView and, when I know the exact number, just use what I have to, and don't use the others... (It's a bad solution)
What do you suggest?
Thank you for your answers!
You should create a ListView, which inflates TextView for the items you have.
You can use this example of how to create sectioned ListView, which will look exactly like you want.
I'm not familiar with Android, so other people may offer better, more specific advice.
In the environments I'm familiar with, the problem of displaying an unknown number of items is solved by using not a series of display elements for each data item but a list control. The list component will display as many items as you give it, and can usually be modified to have different appearance for different data, so you're flexible in making it as pretty as you want.
Well you can consider this one also,
Create a table layout in XML, give it a id: TableLayout table=(TableLayout)findViewById(r.id. ....)
Create dynamic TextViews using: TextView day=new TextView(this); day.setText(day name);
Now add this text view to your table layout : table.addView(day);
Run the code for textView creation and addition to table in loop
Hope this helps...............

Categories