views:

594

answers:

1

i have been developing iphone apps for a while now. I just started on android and have about half of my app done.

My app calls the native datepicker which the user selects the date then on the selection of the date a particular image is show in the format 2010-3-24, same as android output.

I have used the date picker tutorial to get the datepicker working and displaying the selected text in textview.

What i need is to display the particular image that corresponds to the selected date. The images are local to the app. I have looked for tutorials that would possibly help me out but so far no such luck. It is a very simple problem, i am just new to the platform.

A: 

So you would take the Date that comes back from the DatePicker and do some sort of conditional statement to determine what image to display in an ImageView.

What exactly are you having trouble with? Are you having trouble with the conditional statement that would determine the image to use? If so you need to give us more information on how you want that to work.

Are you having trouble getting an image to display in an ImageView? If so show us what code you have tried and we can help you with that.

mbaird
I am having trouble with the conditional statement that will pull the correct image.In my iphone app (sorry to refer to it but only way i know how to demostrate) i take the datepicker results, assign them to a variable then simple take that varible and with javascript on webview insert it in the html with a document write ("<img src=" +varible+".gif/>) then have the option to refresh which will bring up datepicker again.Just doesn't seem to be that easy with this enviroment
matt
Why couldn't you do it exactly the same in Android using an Android WebView? If you could provide some code to show what you have so far maybe I could be more helpful. Are you using an ImageView or a WebView? What have you tried so far that isn't working? It kind of sounds like you got the date picker done, and then just stopped. If you need help writing the specific conditional statement to handle selecting the image, then you need to give much more info on how that is supposed to work in order for me to help you.
mbaird
By the way, "easy" is a relative term. Going from using a programing language you know to one you don't know is obviously going to make things seem difficult at first. But just because you don't know the Android API yet doesn't mean things are more difficult to do in Android.
mbaird
well i tried this in webview, which was working with jquery and a different date picker, however it was terribly slow, in the emulator. So i moved over to textview and imageview.All i have so far is basically from this tutorial, http://developer.android.com/guide/tutorials/views/hello-datepicker.html, and everything works perfect. I am just confused on how i would pass my variable from textview into imageview to display the particular image. I can get some code up shortly.
matt
by the way, what took me several weeks in obj c, has taken me simply a day in java, i like android so far, but like anything new it takes a bit to get used to.
matt
In the updateDisplay() method in that example, instead of (or in addition to) updating the text view with the date just use the date there to determine the image file to set on your image view.
mbaird
i will try that and post results tomorrow, i was thinking that would be the easiest way, but i thought i would have to use imageview somehow
matt
doesnt look like my naming convention is going to work with android, I cannot add an image that is all numbers for the name, i have tried, i renamed the file to sample.png added it to project and no errors, this is the error "Syntax error on token "20101231", invalid VariableDeclaratorId" from the R.java file
matt
This is because Android will create a Java variable with the same name as the file, and you can't have a variable that begins with a number. Just put a letter as the first character of the file name.
mbaird
ahh i see, i got it working with webview and remote sever. Should be a piece of cake to get it working locally then. thanks for your help
matt