cleveroad / adaptivetablelayout Goto Github PK
View Code? Open in Web Editor NEWLibrary that makes it possible to read, edit and write CSV files
License: MIT License
Library that makes it possible to read, edit and write CSV files
License: MIT License
Kindly check my code below:
I am not able to find click listener
+++++++++++++++++++
private static class TestHeaderColumnViewHolder extends ViewHolderImpl {
TextView tvTitle, tvAddToCartCompare;
ImageView ivProduct, ivRemove;
private TestHeaderColumnViewHolder(@NonNull View itemView) {
super(itemView);
tvTitle = itemView.findViewById(R.id.tvTitle);
tvAddToCartCompare = itemView.findViewById(R.id.tvAddToCartCompare);
ivProduct = itemView.findViewById(R.id.ivProduct);
ivRemove = itemView.findViewById(R.id.ivRemove);
}
public void bind(TestHeaderColumnViewHolder vh, int column) {
tvTitle.setText(arrayListOfItem.get(column - 1).getProduct_name());
Glide.with(getItemView().getContext()).load(arrayListOfItem.get(column - 1).getProduct_image()).into(ivProduct);
**tvAddToCartCompare.setOnClickListener(view -> {
assert addtocartClickListner != null;
addtocartClickListner.addToCart(view, arrayListOfItem.get(column - 1), arrayListOfItem.get(column - 1).get_id());
});**
**ivRemove.setOnClickListener(view -> {
assert removeCompareClickLisner != null;
removeCompareClickLisner.removeFromCart(view, arrayListOfItem.get(column - 1), arrayListOfItem.get(column - 1).get_id());
});**
}
}
+++++++++++++++++++
Kindly help me with solution
Thanks
when run app in persian-fa language get this error
AndroidRuntime: FATAL EXCEPTION: main Process: com.develotter.adaptivetablelayouttest, PID: 27698 java.lang.NegativeArraySizeException: -1 at com.cleveroad.adaptivetablelayout.AdaptiveTableManager.init(AdaptiveTableManager.java:59) at com.cleveroad.adaptivetablelayout.AdaptiveTableLayout.initItems(AdaptiveTableLayout.java:224) at com.cleveroad.adaptivetablelayout.AdaptiveTableLayout.onLayout(AdaptiveTableLayout.java:143) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344) at android.widget.FrameLayout.onLayout(FrameLayout.java:281) at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3145) at android.view.View.layout(View.java:17993) at android.view.ViewGroup.layout(ViewGroup.java:5817) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2755) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2456) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1524) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7520) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:622) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7303) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
RT,and how can I redraw some item when item clicked?
Thank you.
I want to know if it's possible to somehow remove row headers shadow.
I want to hide row headers, I just set their width to 0, but I still can see their shadow.
Can somebody help with that?
Thanks
Hi.
Hello, can you please give me some solution for RTL support.
setLayoutDirection didn't solve it.
Thank you.
When I reload a Activity contains a AdaptiveTableLayout ,sometimes it produce a IllegalStateException, but sometimes not.
java.lang.IllegalStateException: You need to init matrix before work!
at com.cleveroad.adaptivetablelayout.AdaptiveTableManager.checkForInit(AdaptiveTableManager.java:66)
at com.cleveroad.adaptivetablelayout.AdaptiveTableManager.getColumnByXWithShift(AdaptiveTableManager.java:226)
at com.cleveroad.adaptivetablelayout.AdaptiveTableLayout.addViewHolders(AdaptiveTableLayout.java:790)
at com.cleveroad.adaptivetablelayout.AdaptiveTableLayout.notifyDataSetChanged(AdaptiveTableLayout.java:1519)
at com.alphagao.youda.ui.activity.StadiumActivity$3.run(StadiumActivity.java:276)
hi
I need change count rows and columns after notifyDataSetChanged adapter But that does not happen and returns the previous value.
@VadimHalimendikCr
Setting allowBackup attribute on my own application element at AndroidManifest makes an error with AdaptiveTableLayout, as its library Manifest already sets its own value for this attribute. Therefore is required to also set tools:replace="android:allowBackup in order to replace this value.
Error:Attribute application@allowBackup value=(false) from AndroidManifest.xml:10:9-36 is also present at [com.cleveroad:adaptivetablelayout:1.2.1] AndroidManifest.xml:12:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:8:5-24:19 to override.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
I have tried with the scrollview but the table layout goes invisible. Any help folks...
Sample crashes when trying to load a CSV on API level 16, although library works properly
In class BaseDataAdaptiveTableLayoutAdapter in switchTwoRows method on line 72 please change for (int i = 0; i < getItems().length; i++)
to for (int i = 0; i < getColumnCount() - 1; i++)
Thanks
I understand that viewing csv file and supporting dragging required every table cells are the same but it would be great if AdaptiveTableLayout can support multiple type of viewholder in readonly mode. That will make displaying multiple type of data (for each column) with different layouts much more easy.
If I use adapter on kotlin I'm getting java.lang.IllegalAccessError: Illegal class access: 'me class' attempting to access 'com.cleveroad.adaptivetablelayout.ViewHolderImpl' (declaration of 'me class' appears in ...). If I use adapter on java I don't have this problem.
After researching, I found this to be a known issue using Java libraries with Kotlin because of the following:
Java allows accessing protected members from other classes in the same package and Kotlin doesn’t, so Java classes will have broader access to the code.
Do you plan to support Kotlin?
AdaptiveTableLayout is still using Android support libraries. This blocks issue #42 among others. This is the library can't be updated to newer API Levels.
To solve this a refactor to Android X is required.
need only one way scroll at a time vertical or horizontal
I am implementing a sort action when clicking on any column header. What also concerns top left corner header.
Table is sorted by top left corner header by default. If user clicks on any other column header, table becomes sorted by that column. I maintain the visibility of a drawable on headers to show if it is sorting ascending or descending
When playing between column headers everything works correctly. This is, if I click on any column header onBindHeaderColumnViewHolder is called and this drawable is removed from previous column and turns visible on new column header. But drawable is never removed from top left corner header as onBindLeftTopHeaderViewHolder is never called too.
Hello,
I've wanted to display a table with 4 TextViews per item, but the table isn't getting updated when I use my modified version of EditItemDialog(to support the 4 TVs I mentioned above).
The data in the csv gets updated immediately, also if I switch to another fragment and back to the table-fragment, the data's displayed correctly!
How can I fix that?
Code handling EditItemDialog response(GH is bugging...):
`
@OverRide
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == EditItemDialog.REQUEST_CODE_EDIT_ITEM && resultCode == Activity.RESULT_OK && data != null) {
int columnIndex = data.getIntExtra(EditItemDialog.EXTRA_COLUMN_NUMBER, 0);
int rowIndex = data.getIntExtra(EditItemDialog.EXTRA_ROW_NUMBER, 0);
String s = data.getStringExtra(EditItemDialog.EXTRA_SUBJECT);
String t = data.getStringExtra(EditItemDialog.EXTRA_TEACHER);
String r = data.getStringExtra(EditItemDialog.EXTRA_ROOM);
// My attempts to update the layout:
mCsvFileDataSource.updateItem(rowIndex, columnIndex,
CsvFileDataSourceImpl.prepItem(s, t, r));
mTableAdapter.notifyItemChanged(rowIndex, columnIndex);
mTableLayout.notifyItemChanged(rowIndex, columnIndex);
mCsvFileDataSource.applyChanges(getLoaderManager(),
mTableLayout.getLinkedAdapterRowsModifications(),
mTableLayout.getLinkedAdapterColumnsModifications(),
mTableLayout.isSolidRowHeader(),
ScheduleFragment.this);
mTableLayout.setVisibility(View.GONE);
mTableLayout.setVisibility(View.VISIBLE);
//mTableLayout.invalidate();
onFileUpdated(StorageUtils.getScheduleFile(getActivity()).getAbsolutePath(), true); // .getScheduleFile() returns File object
}
}
`
`
public static String prepItem(String s, String t, String r) {
return s + ";" + t + ";" + r;
}
//...
public String getItemData(int rowIndex, int columnIndex, int position) { // helper method for schedule, splits item and returns data at position's index
try {
List<String> rowList = getRow(rowIndex);
return (rowList == null ? "" : rowList.get(columnIndex)).split(";")[position];
} catch (Exception e) {
Log.e(TAG, "get rowIndex=" + rowIndex + "; colIndex=" + columnIndex + "; position:" + position + "\ncache = " +
mItemsCache.toString(), e);
return null;
}
}
`
Best regards,
Felipe
PS: Except for above issue, it works like a charm!
Scroll up or down will be flashing When the content does not fill the entire screen
Really an amzing library, thanks for creating it!
Could you please implement a sort function for column header click event?
Is there a way to add a custom footer view (such as a "load more" cell) to the end of the list in certain situations?
I need to add a full width cell (that doesn't scroll horizontally with the rest of the table) when more data needs to be loaded in and cant figure out how to add this in.
Any help would be appreciated.
Thanks
I am trying to load data from my server. I am fetching the data from the server and feeding it to the table, but it takes around 260ms to get server response and in the meantime if I try to touch and move my finger in the empty section in the table it shows this exception.
Getting error as
AndroidRuntime: FATAL EXCEPTION: main
Process: com.stocksarena.algofox, PID: 11552
java.lang.IllegalStateException: You need to init matrix before work!
Could you please implement an only view mode, so thats not possible to edit the cells?
I would like to use your library only for viewing a table.
Anyone else getting this issue? I'm only running the sample with the demo CSV file.
04-24 11:40:54.124 487-487/com.cleveroad.tablelayout E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cleveroad.tablelayout, PID: 487
java.lang.NegativeArraySizeException: -1
at com.cleveroad.adaptivetablelayout.AdaptiveTableManager.init(AdaptiveTableManager.java:59)
at com.cleveroad.adaptivetablelayout.AdaptiveTableLayout.initItems(AdaptiveTableLayout.java:224)
at com.cleveroad.adaptivetablelayout.AdaptiveTableLayout.onLayout(AdaptiveTableLayout.java:143)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3193)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2666)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2367)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1437)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7397)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
pull_down_activity.txt
First of all, Let me thank you for providing this library. I have used AdaptiveTableLayout to show data in table layout form and it is working perfectly fine.
Further, I want to implement the Pull-Down refresh functionality to load latest data into AdaptiveTableLayout view. For this, I have put AdaptiveTableLayout inside SwipeRefreshLayout. But unfortunately, it is not working. All the time when I try to scroll AdaptiveTableLayout to top (i.e. First position), It stops scrolling and swipe refresh layout is triggered instead of reaching to the first position.
It will be so helpful if AdaptiveTableLayout work with SwipeRefeshLayout just like ListView or RecyclerView.
If it's not compatible with SwipeRefeshLayout then, Then to know whether AdaptiveTableLayout scroll reaches to the top (i.e First position), This will also helpful. So that I can trigger SwipeRefreshLayout manually.
Please refer attached layout file for more information.
Help Appreciated, Thanks.
While I update the data and refresh data using notifyDataSetChanged() action more than three times. Also I changed the size of row and column it works slow. Would you please help here.
My code is as follows.
static class MyAdapter extends
BaseDataAdaptiveTableLayoutAdapter<MyAdapter.ViewHolder> {
@Override
protected Object[][] getItems() {
return cells;
}
@Override
public void onBindViewHolder(ViewHolder viewHolder, int row, int column) {
viewHolder.text.setText(cells[row][column]);
}
// other codes...
}
It works well when dragging is not involved.
When switching columns, the app doesn't crash.
But if rows are switched, it crashes!
I found the following code in the library:
void switchTwoRows(int rowIndex, int rowToIndex) {
for (int i = 0; i < getItems().length; i++) {
Object cellData = getItems()[rowToIndex][i];
getItems()[rowToIndex][i] = getItems()[rowIndex][i];
getItems()[rowIndex][i] = cellData;
}
}
I think getItems().length
should not be used here. It just gives number of rows of my data...
It should be something like getColumnCount() - 1
.
Is it my misunderstanding?
Any comment is appreciate.
I just received a spam email from [email protected] advertising this repository. It seems I've been added to some sort of mailing list also, since there's an unsubscribe link. I have expressed no interest in this and have not agreed to receive any notifications.
This violates the GitHub terms of service, which states:
While using GitHub, you agree that you will not under any circumstances... use our servers for any form of excessive automated bulk activity (for example, spamming), or relay any other form of unsolicited advertising or solicitation through our servers
You may not scrape GitHub for spamming purposes
If you collect any GitHub User's Personal Information from GitHub, you agree that you will only use the Personal Information you gather for the purpose for which our User has authorized it
例如布局有两个控件A和B,我想给控件A设置点击事件,在SampleLinkedTableAdapter里设置但是没效果,
adapter设置代码如下:
@OverRide
public void onBindHeaderRowViewHolder(@nonnull ViewHolderImpl viewHolder, int row) {
TestHeaderRowViewHolder vh = (TestHeaderRowViewHolder) viewHolder;
vh.tvText.setText(mTableDataSource.getItemData(row, 0));
vh.img.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
Log.e("data", "点击事件");
}
});
}
Hi,
Thanks a lot for this library.
Is it possible to fix a certain column at the top where the header is or below it so it doesn't leave screen while scrolling down? Also, same goes for row, whereas, I would like to pin certain column there instead of the row header?
@yarovoiag-cr @ilchenko-peter
How to drag and drop multiple elements at the same time?
hello thanks for your useful lib, i try to use this lib for an persian app and i need use Right to left of this table , i don't idea
I can't use Kotlin.
I use thos code in java works but in kotlin crash..
mCsvFileDataSource = CsvFileDataSourceImpl(this, null) tlPipeline = findViewById<AdaptiveTableLayout>(R.id.tlPipeline) mTableAdapter = SampleLinkedTableAdapter(this, mCsvFileDataSource) tlPipeline.setAdapter(mTableAdapter)
Is it possible to resize columns (auto and manuel) according to their contents?
The UI is pretty good. is there any way adding data using List rather than CSV file
can u help me to read from xls file and display using your adaptive able by the way i can get cellule by cellule from my excel using Jecxel API (student project mobile application in android studio still beginner)
I am using this library for the pagination:
https://github.com/tosslife/PullLoadView
But I can not integrate it with the AdaptiveTableLayout
The method onActionUp of AdaptiveTableLayout will be triggered whenever touchUp happens. May the method content be wrapped with 'if(mState.isDragging())'?
code line 1383,like
@Override
public boolean onActionUp(MotionEvent e) {
if(mState.isDragging()){
// remove shadows from dragging views
mShadowHelper.removeAllDragAndDropShadows(this);
// stop smooth scrolling
if (!mScrollerDragAndDropRunnable.isFinished()) {
mScrollerDragAndDropRunnable.stop();
}
........
}
return true;
}
First of all, Let me thank you for providing this library.
I worked for Best mobile app development company in Bangalore. . I have a few doubts that how to write backend code for travel portal development.
When my table have 1 column and screen orientation changed; table structure falls apart.
Trying to use this lib together with AppBarLayout, to scroll Toolbar up before scrolling view itself. For this, i wrapped table containing layout to NestedScrollView, but can't achieve proper work - looks like TableLayout does not support such behavior. Could you please take a look?
I have an adapter with small views that do not fill the entire width of screen. So my question is how to make it fill entire screen's width.
Thanks advance
I get following exception when trying to use AdaptiveTableLayout when loading an adapter with no data. Same happens on sample if loaded an empty CSV:
java.lang.NegativeArraySizeException: -1
at com.cleveroad.adaptivetablelayout.AdaptiveTableManager.init(AdaptiveTableManager.java:59)
at com.cleveroad.adaptivetablelayout.AdaptiveTableLayout.initItems(AdaptiveTableLayout.java:253)
at com.cleveroad.adaptivetablelayout.AdaptiveTableLayout.setAdapter(AdaptiveTableLayout.java:312)
at com.cleveroad.sample.ui.TableLayoutFragment.initAdapter(TableLayoutFragment.java:316)
at com.cleveroad.sample.ui.TableLayoutFragment.onCreateView(TableLayoutFragment.java:134)
cant able to iterate the header columns as data cell columns so we cant able to set different column width for each cells
how to pass custom object array list without using csv file? how to update particular cell?
AdaptiveTableLayout is compiled to API Level 28. This should be updated to API Level 29, the last one at current time.
I construct an adapter with small views that do not fill the entire width or height of the screen. When I try to scroll now, the content flickers between the top and bottom of the AdaptiveTableLayout. When I make the cells large enough everything is fine, though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.