Android - How to show list data without scrolling - java

This is my application require :
- Get data from a server (JSON)
- Show all data report like image above. Data will display as multi page ( do not scroll), use next and previous button to switch
See how I want:
I can get data from server and show data as listview. But I have some problem and need help.
1. How to display data like image I attached. I found some way but seem it is not good
2. How to display data as multi page. I do not know exactly how much data because it depend data on Server, i have to show all data on server. Pages should auto generate depend on data.
Thanks you.

Simplest way to do it would be to create three datasets (let's say arraylists) and keep previous page data in one and current and future in the next one.
Then put an onClickListener that changes the data in listviews and then notify adapter using .notifyDatasetChanged().

This is not an default Android Behavior, So Please do not follow this design. Better to use Load More Functionality :)
You can refer links for that.
ListView to load more items when reached to an end
LoadMore library
Infinite Scroll ListView

Related

Java ADF "showPrintablePageBehavior"

I currently have many rows on a table that load as a user scrolls down the page.
There is a showPrintablePageBehavior tag added to create a printable layout page upon clicking that will show the contents on the table. Currently, it only shows 25 or so rows at a time.
I am trying to figure out how to display every row on the new page once the button is clicked.
Is there anything I can add to the <af:showPrintablePageBehavior/> tag or the af:commandToolbarButton tag that could help transfer all the rows over? I know fetchSize may be an option, but I'm not sure how to implement that in.
Thank you!
To my knowledge, the showPrintablePageBehavior will not trigger a server go around. This means that you need to build another page where you fetch all data (set the fetchsize to -1) and print this. This blog https://myadfnotebook.blogspot.com/2011/01/adf-printable-pages-fetching-more-data.html shows how to do this.

Show SQLite data in a WebView HTML table

I'm writing an Android app (4.2 and above) to return the details of an item from a location on a warehouse shelf.
The locations are fixed as an id for each cell of a HTML table. For example, the centre location has id="0,0". The HTML table is called from a WebView and will act as the GUI for the app. As such, I have three questions:
How can I get the HTML table to dynamically show the item for the corresponding record from the SQLite database?
How can I show the items on different shelves?
How would I make the cells selectable so that I can see further information about an item?
After a lot of searching, I've found posts on how to do this in Python, PHP and C, but nothing much in the way of doing it using Java/JavaScript.
As this is my first question, please let me know if you require any additional information. Cheers!

Tracking data offset of data in a table to retrieve the previous/next subset on table scroll

I am writing a browser based application using GWT and making use of websql (yes, I know it is deprecated). I have created a custom table widget (based on FlexTable) and enabled it to scroll with the help of some CSS trickery. What I am striving to achieve (without much success) is that when the user scrolls to the start/end of the current data in the table, an event is fired and the next subset of X rows is returned from the websql DB and replaces the data currently in the table. In order for this to work, I need to keep track of the data offset in the table widget so that I can pass this to the query and use the limit and offset functions of SQL to return the required data. However, I just cannot seem to get the logic right to implement the data offset tracker within the widget. Another complication is that I need the table to be able to scroll 'into the past' (so to speak), so that it can retrieve data from before the initial start point when the table loads.
I have been at this for a number of days now and just cannot seem to get it right. So I was wondering/hoping that someone might be able to point me in the right direction (PLEASE!).
Thanks in advance
Tim
I am not sure why this is causing a problem.
int page = 0;
// when you hit the bottom
page++;
loadData(page);
// when you hit the top
if (page > 0) {
page--;
loadData(page);
}
Tim I think it is not a good idea controlling the scroll with CSS trickery.
I have done something similar soon and controlling all the logic (pagination, scroll positions,...).
What I suggest to use is a gwt's scrollPanel, a HasData widget (like a cellList) your custom AbstractCell (class which is rendered for each row of your list) and asyncDataProvider ( which gives you the onRangeChange handler for asking to your server when the range data display has changed).
You can force/fire that event when in scrollPanel.addScrollHandler detects you are arriving to the end.
If you want to see all of this in action have a look into (click on source code): http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwCellList
EDIT [according comment below]:
A. If you want to override the data (in the example is X+X+X...) with the new retrieved just maintain always the same range of data displayed [display.setVisibleRange(0, newPageSize);], and start from 0 when you render the new data (on your RangeChange listener).
B. If you need to have control over up and down scrolls instead of taking advantage of the used events internally on the cellList (basically onRangeChange), you can create your custom events and fire them (this option could be easier for your colleagues for understanding everything). And do not worry about controlling up and down scrolls, inside the ShowMorePagerPanel.java you can see a simple example of knowing up and down controls.
Anyway, I did not explain more detailed because I did not see you very convinced to use CellList approach (and I was using my tablet :D ).
If you change your mind, just let me know and I write for you a proper example step by step (this part could be tricky, so if you are lost it is normal ;) ).

Filling the Android layout with elements

To clarify this - what I want to do is:
a) to open a http request to obtain some XML
b) parse that XML
c) given the (fixed) number of elements, put them with a bucle in the layout.
What I am missing is the last part. An example is 'twicca' or just the official Twitter application, that fills the layout with tweets. I want to do something like that. How should I proceed?
My first thought was creating a fixed number of TextView and change those TextView (TextView1, TextView2, ...) with the content I wish. But that doesn't sound very professional...
The standard way to do this in Android is with a ListView (link to developer guide), which automatically creates as many items as needed from the data source. Most examples show pulling from a local SQLite database, but after you've loaded your XML items into an array in memory you can use an ArrayAdapter as the data source for the ListView.

pagination when using listview in android

Hi am developing an android application and i want to implement the pagination while displaying a list view into an activity.
I had seen many example related to this but none has solved my problem. That's why i posted this question here.
for implementing listview into the application i had developed a custom class which extending extends ArrayAdapter<BoObject> and am passing a List < MyCustom Class > into this like
new MyListAdapter(CurrentScreen.this, R.layout.show, customobjects);
For iteration I need to use the customobjects list am first getting , and i don't want to querying for server each time the more button gets clicked.
Can anyone please give a solution for my issue.?
You can try the ViewPager (use it both on Gingerbread [needs to include the supportV4 package] or on ICS), this is used when you want to scroll from left to right by a gesture, even with this ViewPager you can directly snap to a page. On the other side, you can use a ViewSwitcher
too.
Both solutions lets you define a bunch of "Pages", with both View objects you can set the current page and so you can navigate forward or back to the previous page.
there is a solution :
get 100 items in each request from server , insert them to database (sqlite) and read from database every 10 item then display them in list (pagination 10) .
when there is no more item in db send last item id to server and request for next 100 items from server . save them to db and do the routine again .
hope this helped .

Categories

Resources