Comments (19)
In previous version of the library I can easily overload the getView
and hence apply any clickListener
for the row if needed plus I was also implementing a longclickListener
to expand my row view. So you need to make getView
not final please.
Currently I am reverting back to old version of the library that is 1.0.1 which lets the getView
override.
from sortabletableview.
So, the height of a row is defined by the cell with the biggest height. So by defining your cells you define the rows passively. It's the same for the padding. You can not define the padding for the full row, but for the cells inside your row.
I will create an ExpandableTableDataAdapter for you at the weekend.
from sortabletableview.
Have a look at the ExpandableTableDataAdapter. Just make your adapter extend the ExpandableTableDataAdapter and implement the ExpandableTableDataAdapter#getCollapsedCellView()
and ExpandableTableDataAdapter#getExpandedCellView()
method.
from sortabletableview.
Hi @agapaymarlo,
to get shure that I understood you correctly: You want to create a TableView with a custom Cell layout. Is this what you are trying to achive?
Best regards,
Ingo
from sortabletableview.
hi @ISchwarz23
no, i just want to implement it on the whole row, (inflate). right now, we can change only the colors per row.. but is there any way that i can inflate my xml layout? i try to overwrite the public final View getView() on my own adapter, but i cant, because its final.
thanks in advance
marlo
from sortabletableview.
I'm not sure if I got you correctly, but if you want to have an example on how to inflate a custom layout in the TableDataAdapter
have a look to the CarTableDataAdapter
in the example app. To get the inflater simply use the getLayoutInflater()
method.
If you want to set a background color for a specfic cell, simply set the color as the background of the view in the specific cell. I adapted the CarTableDataAdapter
to show a color in the price column that indicates how expensive a car is:
@Override
public View getCellView(final int rowIndex, final int columnIndex, final ViewGroup parentView) {
final Car car = getRowData(rowIndex);
View renderedView = null;
switch (columnIndex) {
case 0:
...
case 3:
renderedView = renderPrice(car);
break;
}
return renderedView;
}
private View renderPrice(final Car car) {
final String priceString = PRICE_FORMATTER.format(car.getPrice()) + " €";
final TextView textView = new TextView(getContext());
textView.setText(priceString);
textView.setPadding(20, 40, 20, 40);
textView.setTextSize(TEXT_SIZE);
if (car.getPrice() < 50000) {
textView.setBackgroundColor(0xFF2E7D32);
} else if (car.getPrice() > 100000) {
textView.setBackgroundColor(0xFFC62828);
}
return textView;
}
from sortabletableview.
I think you just want to replace:
final LinearLayout rowView = new LinearLayout(getContext());
with a custom view. I'd refactor it into it's own method and override it. It'd be helpful for me too, sometimes I need the the row to be different based on the data, I'm not sure if I can do the with the colorizer stuff. I may submit a pull request for this.
from sortabletableview.
But if you replace the LinearLayout
for certain columns it will look no longer like a table This LinearLayout
is used to have the columns. If you do this on your own, you also need to manage the column weights on your own. I don't think that this is a good approach.
To be sure that I understood you correctly and to find a solution for your issue, it would be perfect if you can provide a mockup showing the expected result.
from sortabletableview.
I was thinking something like
protected LinearLayout createRow(rowIndex) {
return new new LinearLayout(getContext());
}
Subclasses could override it to create their own and set any other props or inflate it from xml, it would still have to return a LinearLayout.
Right now I can get around by just doing my extra stuff in getView() something like this:
if (columnIndex == 0 && rowHasBorder(data)) { //only need to do this once per row
parentView.setBackground(getResources().getDrawable(R.drawable.bottom_border ));
}
from sortabletableview.
So, you want something like a TableDataRowColorizer but instead of giving a color you want to have the possibility to give a drawable?
from sortabletableview.
Since version 2.1.0 the TableDataRowBackgroundProvider
is available which replaces the TableDataRowColorizer
. You have now the posibility to specify drawables as row background instead of only colors.
No you can achive your aimed behaviour:
public class BottomBorderBackgroundProvider implements TableDataRowBackgroundProvider<MyData> {
@Override
public Drawable getRowBackground(final int rowIndex, final MyData data) {
if( hasBottomBorder( data ) ) {
return getResources().getDrawable(R.drawable.bottom_border);
} else {
return getResources().getDrawable(R.drawable.default_background);
}
}
private boolean hasBottomBorder(final MyData data) {
// your logic goes here
}
}
and set this to your table:
tableView.setDataRowBackgroundProvider( new BottomBorderBackgroundProvider() );
from sortabletableview.
Hi Ahmad,
I really do not like to remove the final from the getView method as this would allow miss-use of the TableView. There has to be a very good reason for removing it.
Best regards,
Ingo
from sortabletableview.
Reason is pretty valid, I want to have a click listener on the whole row. In a rare case I also want to expand the row to show more information on long click listener. If you can provide some other click listener api or interface and favorably long click listener too,with index and row item access, than I can update to version two.
Usecase. We don't always use table view to just show information but sometime we also want to act on that row, clicking columns can be difficult on little screen.
In my use case I am showing a list of jobs to be completed in a project. Job status, name and description is in table row, now on clicking the job (row) user can go to a job detail page to act on the job and by long clicking users can expand row, to view some buttons below it, to change the job status quickly without details. So depending on the item case I would override the (row) view to make it expandable, or clickable or not.
from sortabletableview.
Hi Ahmad,
as you said, as the screen is pretty small, I don't know if adding buttons inside the table is the best solution. Never the less, the listeners for clicking on data items have a look at 'TableDataClickListener' or for long clicks see 'TableDataLongClickListener'. There are a lot more listeners available.
Best regards,
Ingo
from sortabletableview.
Thanks, I did not notice that, I think added recently. One problem is solved yet the expandable view or custom view problem not... :-)
from sortabletableview.
The click listener was always there, only the long click listener was introduced in 2.2.0.
Custom views are also no issue. Just implement a custom TableDataAdapter. For the "expanding" of rows there is no native support by this library, but I could give you an example how you could realize it. :)
from sortabletableview.
I work for DgHeating, UK and they really like the table view :-), I have already updated the tableView version to latest, That will be good if you could guide me to how can I expand row view on long click.
Another thing I want to know is how can I give height
and padding
to rows? I need to give padding to columns, before version 2 I was setting this to row which I would override in getView
.. Is that the right solution? Documentation may be not complete..
from sortabletableview.
What kind of TableDataAdapter do u use? The SimpleTableDataAdapter or a custom one?
from sortabletableview.
Yes a simple TableDataAdapter with extended SortableTableView. Uploaded for you TableDataAdapter, TableView.
from sortabletableview.
Related Issues (20)
- Apply sorting on date column: HOT 8
- table responsiveness HOT 3
- How do I get the cell content? HOT 1
- "Mark" selected row without using a custom TableView Adapter? HOT 2
- where use simpletabledataadapter#setTextsize HOT 3
- Horizontal Scroll and Vertical Scroll HOT 2
- CheckBox to TableHeaderAdapter HOT 1
- Text alignment in the SortableTableView HOT 1
- Implement custom TableDataRowBackgroundProvider without re-populate table HOT 2
- Table Scrolling HOT 2
- Add footer view HOT 4
- Part of row's background gets white after long click
- inflating class de.codecrafters.tableview.TableView HOT 1
- Merge cells in a row HOT 1
- SortTableView scroll problem
- I want just find solution this. onclickData problem. - read one single cell value. If you can tell tips HOT 3
- Records are not showing using Kotlin
- reference Tableview is null
- onDataClickListener and onDataLongClickListener HOT 2
- Getting Duplicate class found error after adding this dependency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sortabletableview.