TableView icon indicating copy to clipboard operation
TableView copied to clipboard

The rows get miss-aligned when scroll horizontally

Open aditeTestAndroid opened this issue 6 years ago • 32 comments

Hi. this library is really helpful thank you for it. I am using this table view in multiple activities and fragments.Its like clicking on first table view's button directs to other table-view. Problem is that when first load the table view data and scroll horizontally,it miss aligned rows as mentioned in this: https://github.com/evrencoskun/TableView/issues/75#issuecomment-380322778. there is very important for me. please please help me and fix this bug. thanks.

aditeTestAndroid avatar Dec 21 '18 13:12 aditeTestAndroid

Hi, I think I have the same issue. I basically started with the example from the readme.md and extended the missing classes from the sample application and then added some of my data. It happens with a dataset of about ~1800 rows and ~40 columns.

I attached a screen capture. In the second half you can see that for some misaligned rows, if I hit the right one, I can even scroll only a part of the table horizontally.

device20190130221633

mettyw avatar Jan 30 '19 21:01 mettyw

Hi @mettyw ,Did you find any solution for above issue?

aditeTestAndroid avatar Feb 22 '19 09:02 aditeTestAndroid

Hi @aditeTestAndroid no, not really. But it became less urgent: after I implemented proper column row and cell layouts with more padding the issue is virtually gone for my main test device. I guess this is because I now show less items on the screen at the same time. I think this is a timing or synchronization issue of some sort.

But even if it is not happening on my main test device anymore I fear that users of my app with larger screens or less powerful devices are still affected.

mettyw avatar Feb 22 '19 12:02 mettyw

Hi @mettyw Thank you for your reply. As my app is basically for Tablet devices and i am facing this issue very frequently. Can you share your column and row layouts here? it will be helpful.

aditeTestAndroid avatar Mar 18 '19 07:03 aditeTestAndroid

@Override
public int getColumnHeaderItemViewType(int columnPosition) {
    return columnPosition;
}

@Override
public int getRowHeaderItemViewType(int rowPosition) {
    return rowPosition;
}

@Override
public int getCellItemViewType(int columnPosition) {
    return columnPosition;
}

LunevNF avatar May 17 '19 15:05 LunevNF

Has anyone found a solution to this other than reducing the amout of visible cells yet (i already just have about 50 cells on display)? @nikitoSha comment didn't help me at all...

tva-TIS avatar Jun 14 '19 10:06 tva-TIS

Has anyone found a solution to this other than reducing the amout of visible cells yet (i already just have about 50 cells on display)? @nikitoSha comment didn't help me at all...

Hi, @tvaTIS . Try to set like this in adapter:

@Override
public int getColumnHeaderItemViewType(int columnPosition) {
	return 0;
}

@Override
public int getRowHeaderItemViewType(int rowPosition) {
	return 0;
}

@Override
public int getCellItemViewType(int columnPosition) {
	return columnPosition;
}

LunevNF avatar Jun 17 '19 12:06 LunevNF

Hasn't changed anything either. I found out that the problem doesn't occur when the table is build entirely at once with setAllItems (so without calls to addRow or addColumn), so that is gonna be the way i'm gonna go with for now. Thanks anyway.

tva-TIS avatar Jun 18 '19 10:06 tva-TIS

@tva-TIS I also met the same problem. If I replace the CELL content for many times, it will appear disordered display. Have you solved your problem? @nikitoSha I tried your method, but it didn't work,im use 0.8.9.2 version please Help me ,thanks @mettyw How did you solve the problem?

fiterzs avatar Jul 31 '20 09:07 fiterzs

@fiterzs

@tva-TIS I also met the same problem. If I replace the CELL content for many times, it will appear disordered display. Have you solved your problem?

As I wrote, the problem only occurs when addRow or addColumn is called in my project. Maybe setting content does too. I solved it by tossing the table whenever the data changes and rebuild it entirely. Not very efficient but does the job...

tva-TIS avatar Jul 31 '20 09:07 tva-TIS

@fiterzs Can you share the sample project with this bug? Clear empty project with your adapter, layout, init-class? I will try this and correct it. After - publish normal variant.

LunevNF avatar Jul 31 '20 09:07 LunevNF

You can create zip-archive with sample project and share via dropbox or google disk

LunevNF avatar Jul 31 '20 09:07 LunevNF

@nikitoSha Thank you,I have uploaded the simple project Click the ABCD button several times at random and move the view to the last area. You will see this error https://github.com/fiterzs/test @tva-TIS Thank you Again

fiterzs avatar Jul 31 '20 10:07 fiterzs

@nikitoSha I tested it, and this problem exists even in the demo example Scroll the view to the end, just replace the content of any column, the alignment of the table will be problematic It shows the same situation as @mettyw Can you share how you solved this problem? Thank you

fiterzs avatar Aug 03 '20 02:08 fiterzs

is easy to happen after 12 columns. If I fill in blank cells, can find that the cell size is not the same as the previous cells after 12 columns.

fiterzs avatar Aug 03 '20 02:08 fiterzs

@fiterzs Hi, I'm very busy, but I will try to help today. Content replacement - yes, I have the solution. I will do it today and answer

LunevNF avatar Aug 03 '20 02:08 LunevNF

thank you very much for your help, it’s okay, fix this error when you are free Thank you again

Nikita [email protected] 于 2020年8月3日周一 10:42写道:

@fiterzs https://github.com/fiterzs Hi, I'm very busy, but I will try to help today. Content replacement - yes, I have the solution. I will do it today and answer

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/evrencoskun/TableView/issues/202#issuecomment-667773444, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQOU2MZQNBSNTOCHPQ52Y73R6YPZVANCNFSM4GLX5RVQ .

fiterzs avatar Aug 03 '20 04:08 fiterzs

@fiterzs Hi, do you resolve this issue? If no, so your solution is (in file Edsanzhu.java):

    @Override
    public void onClick(View v) {
        Cell cell;
        ArrayList<Integer> result = new ArrayList<Integer>();
        String id;
        switch (v.getId()){
            case R.id.buttonA:
                result = mangerTable.setBlank();
                id =result.get(0).toString()+"-"+result.get(1).toString();
                cell = new Cell(id,"A");
                cell.color = Color.RED;
                Log.d("Tag","Cell id ="+id);
                tableViewAdapterMain.changeCellItem(result.get(0),result.get(1),cell);
                break;
            case R.id.ButtonB:
                result = mangerTable.setPlayer();
                id =result.get(0).toString()+"-"+result.get(1).toString();
                cell = new Cell(id,"B");
                cell.color = Color.BLUE;
                Log.d("Tag","Cell id ="+id);
                tableViewAdapterMain.changeCellItem(result.get(0),result.get(1),cell);
                break;
            case  R.id.ButtonC:
                result = mangerTable.setTie();
                id =result.get(0).toString()+"-"+result.get(1).toString();
                cell = new Cell(id,"C");
                cell.color = Color.GREEN;
                Log.d("Tag","Cell id ="+id);
                tableViewAdapterMain.changeCellItem(result.get(0),result.get(1),cell);
                break;
            case  R.id.ButtonD:
                result = mangerTable.setBack();
                id =result.get(0).toString()+"-"+result.get(1).toString();
                cell = new Cell(id," ");
                //   cell.color = Color.GREEN;
                Log.d("Tag","Cell id ="+id);
                tableViewAdapterMain.changeCellItem(result.get(0),result.get(1),cell);
                break;
        }

        tableViewAdapterMain.getCellRecyclerViewAdapter().notifyDataSetChanged();
        //tableViewAdapterMain.getColumnHeaderRecyclerViewAdapter().notifyDataSetChanged();
        //tableViewAdapterMain.getRowHeaderRecyclerViewAdapter().notifyDataSetChanged();
        mainTableview.scrollToColumnPosition(result.get(0),result.get(1));
    }

So, after that, you just need to complete this, because if you comment scroll to column, you can see, that your columns header row is scrollable (I don't know why, cannot search the reason now).

LunevNF avatar Aug 07 '20 21:08 LunevNF

@nikitoSha Thank you very much for your help. Your method can indeed solve the problem of cell alignment, but the scrolling of rows and columns is still not precise. I don’t know if there is a way to get the column numbers visible on the left and right sides of the tableiew in the currently displayed content For example, the currently visible column number on the left and the largest visible column number on the right

Thank you again

fiterzs avatar Aug 08 '20 01:08 fiterzs

@fiterzs Hi, do you resolve this issue? If no, so your solution is (in file Edsanzhu.java):

So, after that, you just need to complete this, because if you comment scroll to column, you can see, that your columns header row is scrollable (I don't know why, cannot search the reason now).

After the 12th column, the display of rows and columns cannot be aligned. But the alignment problem of CELL is solved I am also very confused about this problem, thank you very much for your help, sorry to trouble you

fiterzs avatar Aug 08 '20 03:08 fiterzs

@fiterzs okay, I will check it now

LunevNF avatar Aug 08 '20 05:08 LunevNF

For example, the currently visible column number on the left and the largest visible column number on the right

This library doesn't support this feature yet for now. You can indicate info (for a example using TextView) about scroll opportunity to the right, or duplicate your main table with one column and place it on the right. When user scroll main table to the end (right), you just set visibility to GONE, and set to Visible, when main table hides last column

LunevNF avatar Aug 08 '20 09:08 LunevNF

@nikitoSha

okay, I will check it now

Thank you for your contribution. To express my gratitude, I would like to buy you a cup of coffee. Please give me your paypay account, If this problem is difficult to solve, I will look for other solutions, thank you again for your kind help

fiterzs avatar Aug 08 '20 09:08 fiterzs

@nikitoSha

okay, I will check it now

Thank you for your contribution. To express my gratitude, I would like to buy you a cup of coffee. Please give me your paypay account, If this problem is difficult to solve, I will look for other solutions, thank you again for your kind help

How fast you need to solve this problem?

LunevNF avatar Aug 08 '20 11:08 LunevNF

@nikitoSha

okay, I will check it now

Thank you for your contribution. To express my gratitude, I would like to buy you a cup of coffee. Please give me your paypay account, If this problem is difficult to solve, I will look for other solutions, thank you again for your kind help

How fast you need to solve this problem? It’s okay, it’s not urgent, when you have free time. I can do other things first.

fiterzs avatar Aug 08 '20 11:08 fiterzs

@nikitoSha Hi nikitoSha. I gave up the original layout, so this problem was temporarily solved. Sorry to disturb you Thank you again for your help.

fiterzs avatar Aug 12 '20 10:08 fiterzs

@fiterzs Hi, Great! Good luck!

LunevNF avatar Aug 12 '20 10:08 LunevNF

@Override
public int getColumnHeaderItemViewType(int columnPosition) {
    return columnPosition;
}

@Override
public int getRowHeaderItemViewType(int rowPosition) {
    return rowPosition;
}

@Override
public int getCellItemViewType(int columnPosition) {
    return columnPosition;
}

Don't know how but this fixed the issue for me :)

aydinozkan avatar Aug 30 '20 10:08 aydinozkan

Has anyone found a solution?

Mohamadkotb avatar Jan 24 '21 13:01 Mohamadkotb

content_container.setHasFixedWidth(true);

Setting this to false solved the issue,

content_container.setHasFixedWidth(false);

where content_container is

   <com.evrencoskun.tableview.TableView
        android:id="@+id/content_container"

ReejeshPK avatar Jun 17 '21 14:06 ReejeshPK