Coder Social home page Coder Social logo

Comments (19)

ahmadalibaloch avatar ahmadalibaloch commented on July 18, 2024 1

In previous version of the library I can easily overload the getViewand 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 getViewnot final please.

Currently I am reverting back to old version of the library that is 1.0.1 which lets the getViewoverride.

from sortabletableview.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024 1

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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024 1

Have a look at the ExpandableTableDataAdapter. Just make your adapter extend the ExpandableTableDataAdapter and implement the ExpandableTableDataAdapter#getCollapsedCellView() and ExpandableTableDataAdapter#getExpandedCellView() method.

from sortabletableview.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

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.

agapaymarlo avatar agapaymarlo commented on July 18, 2024

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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

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.

captrespect avatar captrespect commented on July 18, 2024

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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

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.

captrespect avatar captrespect commented on July 18, 2024

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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

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.

ahmadalibaloch avatar ahmadalibaloch commented on July 18, 2024

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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

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.

ahmadalibaloch avatar ahmadalibaloch commented on July 18, 2024

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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

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.

ahmadalibaloch avatar ahmadalibaloch commented on July 18, 2024

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 heightand paddingto 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.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

What kind of TableDataAdapter do u use? The SimpleTableDataAdapter or a custom one?

from sortabletableview.

ahmadalibaloch avatar ahmadalibaloch commented on July 18, 2024

Yes a simple TableDataAdapter with extended SortableTableView. Uploaded for you TableDataAdapter, TableView.

from sortabletableview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.