evrencoskun / TableView

TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
MIT License
3.14k stars 459 forks source link

Corner View not shown #308

Open aashitshah26 opened 4 years ago

aashitshah26 commented 4 years ago
  This is my xml file

     `<com.evrencoskun.tableview.TableView
    android:id="@+id/tableView"
    android:layout_below="@id/rel"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    app:row_header_width="@dimen/_80sdp"
    app:column_header_height="@dimen/_30sdp"
    app:selected_color="@color/white"
    app:shadow_color="@color/white"
    app:allow_click_inside_cell="true"
    app:allow_click_inside_row_header="true"
    app:allow_click_inside_column_header="true"

    app:unselected_color="@color/white"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    />`

My corner view

`<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="@dimen/_80sdp" android:layout_height="@dimen/_40sdp" android:orientation="vertical" android:gravity="center">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="States/UT"
    android:textSize="@dimen/_12ssp"
    android:padding="@dimen/_5sdp"
    android:textColor="@color/black"/>

`

i have returned this view from method onCreateCornerView()

juanlabrador commented 4 years ago

same problem to me

olegabd commented 4 years ago

@juanlabrador @aashitshah26 There's a bug in the library. If you use methods for separate columns, rows & cells setting instead of setAllItems() - corner view is not added to the layout. I had to fix it for myself manually in the code. So for now there are 3 options:

  1. Wait for the fix
  2. Add the library as a module to your project and fix the problem manually (add code with the corner view adding to the container FrameLayout)
  3. Use setAllItems() method
Zardozz commented 4 years ago

Corner View is currently not shown if any of the column or row headers or cells have no data.

In my case I have column headings but no data for the rows (cells and row headings)> This produces an odd view of:-

image

I think it a fairly normal case if your have column headings you would want to display the corner view (which is a column heading of the row headings)

If you have zero column heading, zero row heading and zero data then you would expect no corner view as well.

As this is a change in behaviour I feel that this should be optional not to break people who expect the existing behaviour.

I have a change prepared to optionally produced:-

image

Once I have fully tested it I'll make a pull request for this.

Mohamadkotb commented 4 years ago

I faced this problem and I found the easiest solution is calling getCornerView() and update view visibility after calling setAllItems() method getCornerView().visibility = View.VISIBLE

juanlabrador commented 4 years ago

@Mohamadkotb no, not works for me. I have to added empty row to end table for showing corner. Thanks @Zardozz

Zardozz commented 3 years ago

This should be able to be closed with the release of 0.8.9.4

You can now call setShowCornerView(true) on the tableView before you set the adapter, so that the cornerview is drawn even if you don't have any row headers (and rows)

Results as per comment https://github.com/evrencoskun/TableView/issues/308#issuecomment-651248087

AppristineMahesh commented 4 months ago

This should be able to be closed with the release of 0.8.9.4

You can now call setShowCornerView(true) on the tableView before you set the adapter, so that the cornerview is drawn even if you don't have any row headers (and rows)

Results as per comment #308 (comment)

This should be able to be closed with the release of 0.8.9.4

You can now call setShowCornerView(true) on the tableView before you set the adapter, so that the cornerview is drawn even if you don't have any row headers (and rows)

Results as per comment #308 (comment)

calling showCornerView = true on the tableView before setting the adapter. However, the corners are not shown.


binding.tableView.showCornerView = true

binding.tableView.setAdapter<ColumnHeader, RowHeader, Cell>(tableViewAdapter)
binding.tableView.setTableViewListener(TableViewListener(binding.tableView))
tableViewAdapter.setAllItems(
    tableViewModel.combinedTableData[0].columnHeaders,
    tableViewModel.combinedTableData[0].rowHeaders,
    tableViewModel.combinedTableData[0].cells
)