Html Table Builder Android


Source link: https://github.com/barisatalay/HtmlTableBuilder

How to display table in Android ? This is library for generate table report in Android. Build in Java. Thank you for developer. its help us!

Android Arsenal License

Html Table Builder

Report Table for Android Projects

Whos uses this library?

TourVisio 2 Mobile

Paximum

Sejour Mobile

Screen Shots

alt tag

Usage

Step 1

allprojects {
 	repositories {
 		... 		maven {
 url  https://jitpack.io  
}
 	
}
 
}

Step 2

Add dependencies in build.gradle.

dependencies {

 implementation  com.github.barisatalay:HtmlTableBuilder:1.0  
}

Step 3 (Create HtmlTableBuilder for Custom class)

HtmlTableBuilder tableBuilder = new HtmlTableBuilder(getApplicationContext(), true);
 tableBuilder.setNoDataText("No Data");
 tableBuilder.setOutOfMemoryText("Due to excessive data, report can not be displayed. Please try again with more applicable search criteria.");

Step 4 (Create table header info)

LinkedHashMap<String, mdlHeaderCell> headerInfos = new LinkedHashMap<>();
 headerInfos.put("id", new mdlHeaderCell.Builder() 			.value("Stok ID") 			.alignment(enmAlignment.LeftJustify) 			.valueType(enmCellValueType.Integer) 			.backgroundColor("red") 			.textColor("white") 			.width(110) 			.build());
  headerInfos.put("name", new mdlHeaderCell.Builder() 		.value("Name") 		.alignment(enmAlignment.LeftJustify) 		.valueType(enmCellValueType.String) 		.fontSize(25) 		.width(170) 		.build());
  headerInfos.put("price", new mdlHeaderCell.Builder() 		.value("Price") 		.alignment(enmAlignment.RightJustify) 		.displayFormat(FormatSettings.DecimalFormat) 		.valueType(enmCellValueType.Decimal) 		.width(175) 		.build());
  headerInfos.put("crtDate", new mdlHeaderCell.Builder() 		.value("Create Date") 		.alignment(enmAlignment.LeftJustify) 		.displayFormat(FormatSettings.ShortDateFormat) 		.valueType(enmCellValueType.DateTime) 		.width(110) 		.build());
 		 tableBuilder.setHeaderInfos(headerInfos);

Step 5 (Create table footer info)

LinkedHashMap<String, mdlFooterCell> footerInfos = new LinkedHashMap<>();
  footerInfos.put("id", new mdlFooterCell.Builder() 		.type(enmFooter.Count) 		.build());
  footerInfos.put("price", new mdlFooterCell.Builder() 		.type(enmFooter.Sum) 		.build());
  tableBuilder.setFooterInfos(footerInfos);

Step 6 (Prepare list row)

List<Stock> result = new ArrayList<>();
 Stock stock = new Stock();
 stock.setId(1);
 stock.setName("Pencil");
 stock.setPrice(getRandomDouble());
 stock.setCrtDate("2018-07-15T22:55:00");
 result.add(stock);
  stock = new Stock();
 stock.setId(2);
 stock.setName("Notebook");
 stock.setPrice(new Double(154562.75));
 stock.setCrtDate("2018-06-11T12:32:00");
 result.add(stock);
  stock = new Stock();
 stock.setId(3);
 stock.setName("Umbrella");
 stock.setPrice(getRandomDouble());
 stock.setCrtDate("2018-04-30T08:07:00");
 result.add(stock);
  tableBuilder.setDataSet(result);

Step 7 (Cell, Header customization)

tableBuilder.setListener(new HtmlTableBuilderListener() {
 	@Override 	public void onDrawCell(int dataIndex, mdlGridCell cell) {
 		boolean isMoneyCol = cell.getValueType() == enmCellValueType.Decimal;  		if ((dataIndex % 2) == 0){
 			cell.setBackgroundColor(!isMoneyCol ? "#F2F7FF" : "#B3D1B3");
 		
}
else if (!isMoneyCol) 			cell.setBackgroundColor("white");
 		else 			cell.setBackgroundColor("#C0DCC0");
 	
}
  	@Override 	public void onDrawColumnHeader(int dataIndex, mdlGridCell cell) {
  	
}
  	@Override 	public void onCalcFields(int rowIndex, LinkedHashMap<String, mdlGridCell> rowData) {
  	
}
 
}
);

Step 8 (Table to WebView)

String htmlPath = tableBuilder.build("table.html");
  webView.getSettings().setBuiltInZoomControls(true);
 webView.getSettings().setDisplayZoomControls(false);
 webView.getSettings().setJavaScriptEnabled(true);
 webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
  webView.loadUrl("file:///" + htmlPath);

Contact me

If you have a better idea or way on this project, please let me know, thanks :)

Email

My Blog

My Linkedin

Resources

The easiest way to use a RecyclerView on Android.

Android Version plugin is a gradle plugin that helps managing version for Android projects. Plugin is especially helpful when you are dealing with complex build structure with multiple flavours and apk splits.

A simple one class TouchListener that can be attached to any RecyclerView and handles multi selection in google photos style via long pressing on an item and moving the finger up/down to select more items (it even scrolls if you reach the edges of the RecyclerView).

Data binding based Android library for validating input.

  • Easy to use
  • Highly customisable

Android Studio / IDEA plug-ins to make Android multi-channel packages.

An Android costomized View to display battery level with charging status.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes