Comments (8)
I have a nexus 7 with 4.3 too. I will try to reproduce the bug this weekend.
Can you post your Adapter?
from tablefixheaders.
Love to!
The data scale is about 20*100 in general.
Thanks. :)
public class MyAdapter extends BaseTableAdapter {
private final float density;
public MyAdapter(Context context) {
density = context.getResources().getDisplayMetrics().density;
}
@Override
public int getRowCount() {
// Row number without fixed part
return mData.rowCount;
}
@Override
public int getColumnCount() {
// Column number without fixed part
return mData.displayTable.size() - 2;
}
@Override
public View getView(int row, int column, View convertView, ViewGroup parent) {
View view;
switch (getItemViewType(row, column)) {
case 0:
view = getFirstHeader(row, column, convertView, parent);
break;
case 1:
view = getHeader(row, column, convertView, parent);
break;
case 2:
view = getFirstBody(row, column, convertView, parent);
break;
case 3:
view = getBody(row, column, convertView, parent);
break;
default:
throw new RuntimeException("wtf?");
}
return view;
}
@Override
public int getWidth(int column) {
return Math.round(mData.displayTable.get(column + 1).width * density);
}
@Override
public int getHeight(int row) {
final int height;
if (row == -1) {
height = 90;
} else {
height = 55;
}
return Math.round(height * density);
}
@Override
public int getItemViewType(int row, int column) {
final int itemViewType;
if (row == -1 && column == -1) {
itemViewType = 0;
} else if (row == -1) {
itemViewType = 1;
} else if (column == -1) {
itemViewType = 2;
} else {
itemViewType = 3;
}
return itemViewType;
}
@Override
public int getViewTypeCount() {
return 4;
}
private View getFirstHeader(int row, int column, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getActivity().getLayoutInflater().inflate(R.layout.item_table_header_first, parent, false);
}
((TextView) convertView.findViewById(android.R.id.text1)).setText(mData.displayTable.get(0).header);
((TextView) convertView.findViewById(android.R.id.text2)).setText(mData.displayTable.get(1).header);
return convertView;
}
private View getHeader(int row, int column, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getActivity().getLayoutInflater().inflate(R.layout.item_table_header, parent, false);
}
// Start from the third column
((TextView) convertView.findViewById(android.R.id.text1)).setText(mData.displayTable.get(column + 2).header);
return convertView;
}
private View getFirstBody(int row, int column, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getActivity().getLayoutInflater().inflate(R.layout.item_table_first, parent, false);
}
convertView.setBackgroundResource((row + 1) % 5 == 0 ? R.drawable.bg_table_highlight : R.drawable.bg_table_normal);
((TextView) convertView.findViewById(android.R.id.text1)).setText(mData.displayTable.get(0).textData.get(row));
((TextView) convertView.findViewById(android.R.id.text2)).setText(mData.displayTable.get(1).textData.get(row));
return convertView;
}
private View getBody(int row, int column, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getActivity().getLayoutInflater().inflate(R.layout.item_table, parent, false);
}
convertView.setBackgroundResource((row + 1) % 5 == 0 ? R.drawable.bg_table_highlight : R.drawable.bg_table_normal);
// Start from the third column
((TextView) convertView.findViewById(android.R.id.text1)).setText(mData.displayTable.get(column + 2).textData.get(row));
return convertView;
}
}
from tablefixheaders.
It isn't an error with 4.3 or Nexus 7. The adapter or the data must have an error but I can't find it.
This error has me quite curious. If you share a simple example which reproduces the error I will debug it. You can upload the code to GitHub, for example.
from tablefixheaders.
The data source is quite complicate, I'll try to reproduce the error with simpler case.
I'm curious too, how can this error not happening on other device..
from tablefixheaders.
Hi, sorry for late reply, I've been very busy lately. :(
I tried running my project on every android device I can get, they all work fine, except for Nexus 7 with Android 4.3.
I upload a test project on here (can't create new repo on GitHub, weird), which can reproduce the problem on my Nexus.
I'm new to this, so please let me know if there's something wrong with the project.
Hope this helps!
from tablefixheaders.
Really strange bug. You can check it with this change: https://github.com/BraisGabin/TableTest/commit/e41470b126c4c2c74811873109e84e9f16df76ba
The TextView.getText()
log the correct value but display another. It seems an Android 4.3 bug but I'm not sure.
If you simplify the layout the issue disappears. For example: https://github.com/BraisGabin/TableTest/commit/655774c6bb5bad661d99eacd7f6a0ed6781d2ef8
from tablefixheaders.
Simplify the layout solving my problem, thank you very much!!!
Still it's a strange bug..
from tablefixheaders.
Hi there, may be you should check this out.
use
convertView = getLayoutInflater().inflate(R.layout.item_table, parent, false);
instead
if (convertView == null)
{
convertView = getLayoutInflater().inflate(R.layout.item_table, parent, false);
}
this may sacrifice performance, but it seems can fix it.
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 HOT 1
- 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.