AndroidPlot, setting different DomainValueFormats - android

I am trying to do the following for the x labels in my graph.
The first label should have format:
plot.getGraphWidget()
.setDomainValueFormat(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"));
All the other labels should only show minutes and seconds:
plot.getGraphWidget()
.setDomainValueFormat(new SimpleDateFormat("mm:ss"));
I can set the Format for all labels, but I can't figure out how to change it for only the first label. My graph is dynamic and changes every second (incoming data gets updated each second with a new value).
Is there maybe a function that could help me? (It's all a bit difficult to find with website being down...) Or any other tips?
Any help is greatly appreciated.

Assuming you have no repeating values in your domain model you could keep track of your first value and test for equality inside a custom Formatter implementation. It's not pretty but because there is no way to pass in the index of the item being drawn to the Formatter that's about the only way I can see doing this.

Related

How to calculate between dates in a ListView in Android and show the result in a new field in the same row?

I am new at Android and also at StackOverflow as a registered user. I have been using this site a lot, but this is the first time that I need help and I could not find an answer.
I need to show in a ListView the diference in days between today and the date picked from a datepicker. I have the data in a SQLite data base. Where should I do the maths for this? In my CursorAdapter Class, or in the Cursor?
Because I need to change the color of the text if the expiration date for doing something is less than 2 days for instance. And that is why I need to do this on my listView to show the user which activities are close to be expired.
I will really appreciate any help. Thanks in advance!
Gretel
Let Sqlite do the math for you by calculating the date difference directly in the database query.
Something like this:
SELECT myNameCol as name, julianday('now') - julianday(myDateColumn) as dayDiff FROM MyTable;
The returned value for dayDiffis the difference in days from now and the value in the myDateColumn column.

How to get current time of action in Android?

How can I get the time an action was performed in the users preset format (24/12Hr)? I'm trying to set a textview with the time an onClick was performed.
EDIT: I've tried
Time currentTime = new Time();
currentTime.setToNow();
However, instead of XX:XX/X:XX I get a bunch of unneeded text.
The question have been asked already, e.g. here.
So, to put current date-time in TextView use the following code:
time.setText(DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()));
If You need only time (without date), then it should look the following:
time.setText(DateFormat.getTimeInstance().format(Calendar.getInstance().getTime()))
Also, checkout getTimeInstance(int style) which allows to use different style of the format (e.g. long, short, medium).

Android: Converting a decimal number to time

Android
Im working on and android application that works out the time it takes to reach a destination.
what I am try to figure out is how to set up the result so the answer can be displayed as hours.minutes.seconds or days.hours.minutes.seconds.
Would I have to set up an array to get a result like this ?
or
Would the above Q be able to slip up the answer?
ie lets say I have an answer of 4.50 (been 4hrs, 30min) would I be able to take the .50 and time it by 0.6 to change the output to 4.30.
or
Can the answer be displayed in a time picker.
ps I have searched this on the forums and google etc. And I have not found and relevent, easy to comprehend answers.
pps Any codes or links would be greatly apprecated thank you.
I think you can use SimpleDateFormat class to do that.
example code:
String datastring="15.32.08"
SimpleDateFormat sf = new SimpleDateFormat("HH.mm.ss");
Date converttoData = sf.parse(datastring);
You can easily do that: First to convert a decimal to string(datastring),second,use upper code.
hope the answer can help u.:)

solution for SQLite function for time difference without java code

Hey please pay attention to solve this problem I know this could be possible but I am not getting the way ..
I am using sqlite in android to store and manipulate the field as shown below in the figure
Figure http://s16.postimage.org/idc13pxdh/image.png
first_start_time,last_start_time,last_end_time are datetime field in SQLite database
I need to get the difference of last_start_time and last_end_time as mean of function so that I don't need to do it programatically
last_end_time = strftime('%Y-%m-%d %H:%M:%S','now','localtime')
last_start_time= strftime('%Y-%m-%d %H:%M:%S','2012-01-27 02:34:56')
,i,e if my firsttime is =2012-06-15 14:54:33
and Endtime is =2012-06-15 14:54:40
then time diff would be like this =00:00:14;
i want to have such difference time like last_end_time -last_start_time
i also want to use trigger to do use in sqlite data base in android
at the last I need that all my total_expended_time should get summed up like ...
select sum(total_expended_time) from study_result
.. one thing keep in mind the result should be in datetime stamp so that i can reflect it to my UI
Any suggestion will be appreciated

Android KeyCodes for combination of letters

I am implementing a custom input method (softkeyboard ) for android...Its a gesture detection keyboard,so I will capture the direction the users swipes and the code for that.In doing so,I have some combination of letters like "Th" and "Ch" for which I would need the int value.The char values can be easily converted ,but how to get int values for combination of characters...Please suggest.
I need getCharacter(code) to return an int.
Only by successive calls to getCharacter().. take a step back and see that this method is not the best point to be implementing what youre trying to do. The handler that returns the multiple chars (strings) should implement getCharacter() successively on every character in the string. If I am understanding the problem correctly.

Categories

Resources