Comments (14)
You can get the X and Y position of the table using these two methods:
tableFixHeaders.getActualScrollX();
tableFixHeaders.getActualScrollY();
Before you start your other activity, get the Y position of the table so you can do something like this:
TableFixHeaders tableFixHeaders = (TableFixHeaders) findViewById(R.id.table);
int x = tableFixHeaders.getActualScrollX();
int y = tableFixHeaders.getActualScrollY();
And when you return back to your activity:
TableFixHeaders tableFixHeaders = (TableFixHeaders) findViewById(R.id.table);
tableFixHeaders.scrollTo(x, y);
from tablefixheaders.
The @ashx1's comment is completely right. However, can't you archive this without setting a new adapter? You can refresh the adapter data and call notifyDataSetChangued().
from tablefixheaders.
Thank you for your suggestion, but it only partially solves the problem.
The tableFixHeaders.getActualScrollY() is only executed (i.e. set different from 0) when the table is actually scrolled down, to reveal new rows. It does not work when the selected row is just touched (without scrolling).
I need to know the precise position of the touched row, not the amount of actual vertical scroll offset, because I need to return to the same row position in the originally touched parent table. This should then activate another activity, based on that specific (return) row position.
Please think about a classic parent > child table relationship: a click on a row in the parent table selects a different set of records in the child table grid - this is precisely how I am using the tableFixHeaders.
Is there another call to the tableFixHeaders library that will give me the vertical (Y) position of the touched row ?
Or preferably, the touched row number ?
from tablefixheaders.
There is tableFixHeaders.getY(); : which is The visual y position of this view, in pixels. This is equivalent to the translationY property plus the current top property.
Maybe you could set the row number as a tag on the row, and then when your row is clicked you can get the tag of the row which means you will get the row number of the touched row?
from tablefixheaders.
Re. Refreshing the adapter data:
I am using lifecycle Callbacks functions to move between activities and fragments. This works perfectly well when pressing back button to return to the parent table grid, which is preserved and in exactly the same position as left before (no need to adjust any scrolling).
However, some other activities can change the data values in the parent table grid and the cell colour of the previously touched parent table row (the edited and saved data rows are marked with a different cell colour).
Currently I use the following code to reset the master grid table after each data / colour change:
SowListF.tableAdapter = null;
SowListF.tableAdapter = new SowListAdapter(this);
SowListF.tableFixHeaders.setAdapter(SowListF.tableAdapter);
SowListF.tableFixHeaders.scrollBy(0, SowListA.LastRowPosition);
The above code forces the SQLite query to extract a new (modified) set of table data, which is then displayed by setting up a new adapter.
Is it possible to refresh the original tableFixHeaders table grid adapter to display the new cell values and cell colour, without setting up the new adapter (as above) ?
How do I make those refresh adapter calls and use it with the notifyDataSetChangued() call ?
from tablefixheaders.
I am not to sure on how to refresh the adapter calls and use it with notifyDataSetChanged, @BraisGabin would be the best person to answer that.
from tablefixheaders.
I cannot find the method tableFixHeaders.getY() ?
There is public method onInterceptTouchEvent which obtains currentY in MotionEvent.ACTION_DOWN, however the currentY is a private (internal) variable, not accessible from outside the library.
There is a public method ScrollTo inside tableFixHeaders (which overrides ScrollTo in View) but I don't know where/how it is called and how to provide the necessary Y value to relayout the table grid.
from tablefixheaders.
SowListF.tableAdapter.forceSQLiteQuery(); // you must implement this
SowListF.tableAdapter.notifyDataSetChangued();
This should work. Although writing forceSQLiteQuery ()
can be more or
less difficult depending on your adapter implementation.
from tablefixheaders.
As @BraisGabin has probably answered your question above. Just on your last comment where you could not find the method tableFixHeaders.getY(), it is there as this is a method in the class View. ViewGroup extends View and TableFixHeaders extends ViewGroup:
http://developer.android.com/reference/android/view/View.html#getX%28%29
from tablefixheaders.
I have got it to work to have the previously touched row to stay visible within the displayed table section, after setting a new adapter to update the table contents. I have implemented it as previously suggested using:
tableFixHeaders.getActualScrollY();
and
tableFixHeaders.scrollTo(0, y);
However, I am having problem with implementing the suggested adapter refresh using the call to:
notifyDataSetChanged(), instead of setting the new adapter each time the table contents gets changed.
I am using the library calls to your TableAdapter, (as per your examples). This library does not include the notifyDataSetChanged() method.
That method is only available in the BaseTableAdapter part of your library, which I am not able to call directly.
Would you be able to suggest how to implement this call to the notifyDataSetChanged(), to gain access to this method. A small example code would be very helpful and highly appreciated.
Many thanks.
from tablefixheaders.
One possible implementation: https://github.com/InQBarna/TableFixHeaders/blob/master/library/src/com/inqbarna/tablefixheaders/adapters/BaseTableAdapter.java
from tablefixheaders.
I have added the method:
@OverRide
public void notifyDataSetChanged() {
mDataSetObservable.notifyChanged();
}
to my application TableAdpater which extends the BaseTableAdpater,
however, I am getting an error message: "The field BaseTableAdpater.mDataSetObesrvable is not visible"
I noticed that in your library, the BaseTableAdapter implements TableAdapter, which includes the above method.
How to overcome this issue and how to call this method directly from my TableAdapter ?
from tablefixheaders.
Maybe instead of mDataSetObservable.notifyChanged(); try super.notifyDataSetChanged();
The super.notifyDataSetChanged(); should call the class method that this class has inherited/implemented from.
from tablefixheaders.
Thank you. That seems to have done the trick.
I now have to develop the second part of the refresh procedure:
SowListF.tableAdapter.forceSQLiteQuery();
as suggested by @BraisGabin.
I will let you know if I have succeeded.
from tablefixheaders.
Related Issues (20)
- How can i use it in a CoordinatorLayout HOT 1
- How can scroll in viewpage when columns stop scrolling HOT 4
- how to remove first column on fix hader HOT 2
- can i set header on image
- java.lang.NullPointerException: at com.inqbarna.tablefixheaders.TableFixHeaders.scrollBounds (TableFixHeaders.java:630) HOT 2
- Want to inflate more than one values in one column
- Issue with UI Thread block HOT 1
- search value in TableFixHeaders
- How to pass model array list to MatrixTableAdapter HOT 6
- How to insert data from api HOT 1
- Scroll issue when i put TableFixHeaders view inside a ScrollView/NestedScrollView HOT 2
- Text Color
- Not running in Tablet HOT 4
- Invalid content set in cell(view) during scrolling up,down or right, left...
- How to adapt the row height by context?
- How to set section header is aligned center on table? HOT 2
- Why does the table get inside the screen? HOT 5
- Android 9.0 landscape will crash
- after horizontal scrolling content get reset HOT 1
- Unable to use the lib
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 tablefixheaders.