I need a line chart that will use adapter like in ListView.
All charts what I saw require array of points as input data. But I have database that contains a lot of points. For drawing this data I should convert selected cursor to an array. It's not suits me. Because in one moment of time on the screen can be displayed scanty part of data. Other points should be displayed only when I do scroll.
Pictures for understanding.
This is what I want:
What hapened when I scroll:
New points should be created only when it's needed.
Hi i don't know whether this solution meet your requirement,But you can try HoloGraphLibrary
Which contain all types of graph including line graph
Wish it will help you,Thank you
Related
I've extended the example app ChartDataAdapater and ChartItems extensively, but am running into a small issue when it comes to updating already created charts in my listview.
For example, one of the charts in my listview is a linechart with multiple series. I give the user the option to modify the series being displayed, and would like to update the chart on the fly. Right now, I'm adding my charts to the ArrayList<ChartItem> like so, and then updating/creating the adapter:
this.listChart.add(new LineChartItem(chartdata, getApplicationContext()));
chartdata will be updated in a background thread, whenever the user changes the series they wish to view..
My question is, how do I reference that LineChartItem and update it? Should I be saving a reference to the LineChartItem and using that to add to the ArrayList? Is there a 'update' method I should be overriding in my ChartItem class?
I understand I'll have to update the adapter (notifyDataSetChanged) after I update the LineChartItem in my ArrayList<ChartItem>, but I seem to having a hard time wrapping my head around the LineChartItem chartdata update.. Thanks in advance.
What you describe seems like an issue related to the ListView in general.
A solution could be that you somehow remember the index of the item the user is currently working on. Then use that index to get the corresponding data item in your list of data items.
Then udpate that data item with the new data, and refresh the listview.
Hello there guys and ladies,
Right now I'm developing a content-providing application, which should be able to get live-ticking content.
So if content is uploaded to a server, the user should get the recent news. It don't have to be imediatly. I'm more thinking of an API-Calling method, which is doing an API-Call every now and then.
But what's more important right now: The content is provided in a List. So after fetching the content i've an arraylist, which is filled with content-objects.
Those content-objects will have a timestamp.
I wanna create a timeline. The thing is, if there is new content coming in, it should be marked. for example in a different color.
So imagine a timeline, when ur looking at the content. Then you put your phone away. and after you looked at the app again, there are e.g. 4 new content-objects available. These 4 content-objects should be marked in the timeline.
Can I dynamically color a listview? or would you rather recommmend another layout-element to reach my goal?
I've never done any design aspect in Android before, so I'm quite lost in this field. Do you guys know any good tutorials or books for designing android applications.
you should use a listview, and then in your list which contains your list view object, you should just add the new elements to it, and call adapter.notifiyDatasetChanged(). this will update your list with the new items. As for the color you could add an object field called color where you could store the hex value for your row, and each time you add new items set thier color to what ever color you want, and unset the other items in the array. then in the adapter change their background color accordingly
I have 2 Fragments, one with my chart and below one with a TableLayout with my TimeChart values. I would like to add to my chart, a function when i click (or hover) one value of my table, a plot draw himself on the chart at specific date and value but i didn't find yet a way to do this. Could some have already done something like that?
Thanks in advance
You can definitely do this. One option would be that you add an extra series that would contain only the extra point you want to render. When you want to render it at another location, just remove the previous one and add another one. Don't forget to call chartView.repaint(); after every such change.
EDIT: After spending almost all day on this OutOfMemory Error I was getting, turns out I simply wasnt advancing a cursor. However, I still wish to obtain an answer for my question below. To clarify, my question is:
Is it faster to make a custom adapter for a listview that hooks directly into the database to retrieve the data, or should an arraylist of that data be made first and then passed into a default arrayadapter?
I am currently working on an application and as a part of one of its functions I need to be able to take data from an internal database and display parts of it in various listviews. These listviews are all linked together in a ViewFlipper to make it easy to move between the views. I am working with about 5000 values maximum at once. (That is the stress size for the data set that I am tasked to work with).
Should I write a custom adapter that directly links to the database and extracts the values, or is there a better way to go about this? I tried to create a sort of wrapper class for the database that would extract all necessary data from the database and place it into a POJO but i keep getting OutOfMemory exceptions (5 string values * 5000 rows = 25000 strings doesnt seem to be nicely accepted in my case).
Not with the same amount of values, 5000 but I had a similar problem.
I ended up using a private arrayList on a ListAdapter, the list will contain only partial lists, for example 100 items.
Your cursor can initially contain the values to fill the firsts 100 items and when you scroll down looking for more items you can launch another cursor to retreive the next 50 items. Controlling a range of 100-150 items at your arrayList by adding/removing new/old items and refreshing the adapter.
I vote up your question because maybe someone find a better way to do it and I would like to know as well.
I need to create a list which will all be programmed in the java code and not XML as the items within the list require processing. The left side will have a string and the right side will have a numerical value for each row. This is somewhat like a listView only slightly different as there are two variables for each row one on the right and one on the left. I need to be able to define and add rows freely in the code. How do I go about in programming this type of list into my application. Thanks in advance for any help.
Please refer to the List3 Example (Cursor (Phones) Example in the API Demos) for an example of how to display columns of different types in a list view.
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List3.html