Comments (8)
- I haven't performance comparatives with other components. A Table view doesn't recycle views and TableFixHeaders does it and therefore the last one should be better. I have a TableFixHeader with more than 300 entries and runs like a charm.
- No and yes. It is not implemented for all a row (or a column). But if in your adapter you implement the listener in all the cells of a row the result is very similar.
- The same as 2.
- You can't. If you have 1000 entries you can't measure all of them for performance reasons. And therefore you can't ensure that all the text wraps.
from tablefixheaders.
Thank you very much for the prompt reply.
That gives me more confidence about using your special component, if you think that point 2 and 3 are feasible.
I will give it a go and will try to implement both point 2 and point 3 OnClick listeners. They are vital to my future application. However I know it is going to be a major challenge, as I am still learning the basics of programming in Android.
I will be using your StyleTable as a template, as I do not require grouping of the records.
Would you be able to suggest where in your SampleTableAdapter would be the best place to add the onClick listeners code ?
I will keep you updated on the progress and will also let you know about the performance of your table grid, once I get the large data set in.
Once again, what you have created is absolutely fantastic.
from tablefixheaders.
After line 58:
converView.setOnClickListener(listener);
from tablefixheaders.
Thank you for a valuable tip.
I have got as far as getting the X,Y coordinates of the clicked cell, using the following code:
public OnClickListener listener = new OnClickListener() {
@OverRide
public void onClick(View v) {
int x = (int) v.getX();
int y = (int) v.getY();
CharSequence cs = "Cell clicked: X=" + String.valueOf(x) + ", Y=" + String.valueOf(y);
Toast.makeText(context, cs, Toast.LENGTH_LONG).show();
}
};
What I really need is the row (int) and column (int) values for the clicked cell, in order to make further progress.
Would you be so kind to suggest how to get the row and column values for the clicked cell in the above OnClickListener procedure (within your SimpleTableAdapter code).
Thank you in advance.
from tablefixheaders.
I have got one additional question related to the previous one.
I would like to get the string value of the clicked column header (in order to alter it by adding a sort order arrow).
I have tried the following:
public void onClick(View v ) {
String titleText = null;
if(v instanceof TextView){
TextView t = (TextView) v;
titleText = t.getText().toString();
};
... and also: String titleText = ((TextView) v).getText().toString();
but none of the above methods appear to work.
I would greatly appreciate your suggestion how to extract the text value of the clicked cell.
Kind regards,
Mariusz
from tablefixheaders.
I have found solution to my last question. Here is the updated code:
public OnClickListener listener = new OnClickListener() {
@Override
public void onClick(View v ) {
ViewGroup parent = (ViewGroup)v.getParent();
int x = (int) v.getX();
int y = (int) v.getY();
CharSequence cs = ((TextView) v.findViewById(android.R.id.text1)).getText();
cs = cs + " clicked: X=" + String.valueOf(x) + ", Y=" + String.valueOf(y);
Toast.makeText(context, cs, Toast.LENGTH_LONG).show();
if (y == 0) { // if clicked on header row cell
for(int col=0; col<getColumnCount(); col++){
//TextView tv = (TextView) findViewById(col);
//View cell = adapter.getView(row, column);
View tv = getView(-1, col-1, null, parent);
setHeaderView(-1, col-1, tv, parent);
}
}
}
};
private View setHeaderView(int row, int column, View converView, ViewGroup parent) {
// if (converView == null) {
// converView = inflater.inflate(getLayoutResource(row, column), parent, false);
// }
setText(converView, getCellString(row, column) + " ↓"); // change the text for a clicked column header
// to be done // reset the header text for all other columns back to their original names
return converView;
}
However, the remaining issue is how to get the view (ids) for a range of header row cells. Those views would need to be identified, based on the table grid coordinates, starting from cell view (-1, -1) up to (-1, getColumnCount())
The code above (commented out) is not working, as I cannot inflate again the existing cell view. I need to use the already assigned cell views, which will allow me to get the existing strings in those header cells and alter them accordingly.
Any suggestions would be most appreciated.
from tablefixheaders.
You can get the clicked cell with this code:
@Override
public View getView(final int row, final int column, View converView, ViewGroup parent) {
if (converView == null) {
converView = inflater.inflate(getLayoutResource(row, column), parent, false);
}
setText(converView, getCellString(row, column));
converView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context, "cell in row " + row +" and column "+ column, Toast.LENGTH_SHORT).show();
}
});
return converView;
}
And I don't understend your last problem. If you have problems with the recycled views I recommend you read the documentation of ListViews. TableFixHeaders follows the same pattern.
from tablefixheaders.
Thank you.
This is exactly what I was trying to achieve.
I can now also solve my header cell editing requirements using the row and column information from the clicked cell.
Your last email was very helpful.
Best regards,
Mariusz
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.