Can we added changing image/text on android app - android

Is there a way in android app that we can add some text or image and we can change that dynamically without adding new version. Like we have this text: Today's deal is: 1
then in a week if i want that text to show as: Today's deal is: 2.
Is there a way to do this, for an app which does not have a server and is stand alone app.

A text or image can be altered during run time; so how you choose to change that is up to you. You would have a simply switch statement depending on the day of the week for your specific example.
TextView tv = (TextView) findViewById(R.yourxml.name);
tv.setText("Monday!");
...

One way I can think of to achieve this is by writing a long value in the shared preferences for a Date object. Each time you start the application we will check if it's been 1 day since the value was saved. Also maintain the different string you want to display as string array in the resources.
I hope it helps...

Related

How to upload text view from android to a database in a website using a button

I'm currently doing a project from one of my subjects in my university. I'm about to do an attendance app that checks if the professors are present, late, or absent in the room based on the schedule. I made an app in an android studio which uses radio groups and radio buttons that will change the text in the text view which will show if the professors attendance status. I'm thinking of making a button that will upload the text views with the attendance statuses to a website which holds the data(database).
I'm not used to programming in the android studio that is why I would like to know if a way to upload the text views on a website. Thanks
It's quite simple, You have to create Weg api that you can call from the android mobile application and pass the current status of the professor or the whatever you want to pass on the server. That api will update the database as per whatever you have passed from the mobile application.
Also, One more thing that you can not pass the text view, you just need to pass the text of that view.
I hope, you will get answer from this.
Happy coding...
Assign value of textview to a string variable.
And use this string in your api to pass data.
For example if you have a textview with name teacher, you can get its value using this line.
String st_teacher = teacher.getText();
Now use that st_teacher value in your api to upload data.

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).

Change textView according to date/time (Java, Eclipse)

I want to create a textView that will change according to date and time. For example, I want to create a textView that'll say "Today is >weekday<". The app will check the date/time on the phone and check which day it is. For example on 6th June 2013 it'll say "Today is thursday".
I'd appreciate any help, thank you!
Yes of course, check out http://docs.oracle.com/javase/6/docs/api/java/util/Calendar.html
All you need to do is create a textview, then get the current day of the week from the Calendar library and set the text of the textview using that information.
To make it dynamic, you'll need to put this in onCreate() and possibly onResume() that way each time that application is created or restarted the content of the textview can be reset.

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

Is there simple way to create user defaults values for TextView in Android?

I'm looking for simple way to create user defaults values for TextView in Android: I need the standart solution that user is seeing the previous value, that was entered by him to the TextView. Sure, there is way to store value of TextView at somewhere and then read it again while starting activity, but, may be, there is any simple tool to get what I wish ?
You can use SharedPreferences to store previous values and then get previous values from shared preferences to set as default values
Just to get your question correctly:
You want to present the values the user selected/set in his last visit?
You can save those values in the SharedPreferences - That's what they're made for.
You can give the google prediction api a try.

Categories

Resources