Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development > Developer 101

Developer 101 101 Tutorials



Reply
 
LinkBack Thread Tools
Old October 22nd, 2011, 05:09 PM   #1 (permalink)
New Member
 
Join Date: Oct 2011
Posts: 8
 
Device(s):
Thanks: 6
Thanked 0 Times in 0 Posts
Unhappy Using Java with Android, help :(

Now I know android works closely with java programming, so android is based off of java.
In my application, I want a spinner, with 8 choices, and when the "spin" button is pushed, I want the spinner to randomly choose one option.
My question is;
Can I create the spinner entirely with java code outside of android and then just insert the code into the .java file in eclipse? I'm familiar with java and would be able to pull this off if you can do it this way.


Booocubs is offline  
Reply With Quote
Sponsors
Old October 22nd, 2011, 05:25 PM   #2 (permalink)
Senior Member
 
TheCompBoy's Avatar
 
Join Date: Oct 2010
Location: Sweden
Posts: 594
 
Device(s): Samsung Galaxy S w DarkyROM v10.1
Thanks: 4
Thanked 56 Times in 51 Posts
Send a message via Skype™ to TheCompBoy
Default

That wont work since you got to make the code so it works with the android OS.. What you want to do is possible, But making android applications isn't as making normal desktop ones.. Try to check this website out if might give you a good start: What is Android? | Android Developers

I also recomend maybe doing some smaller applications before you start your bigger projects.
__________________
Please check out my blogg: www.thecompboy.blogspot.com
If you want to support me please subscribe / follow the blogg!

OCalc - First App: https://market.android.com/details?id=mendel.calculator.simple&feature=search _result
TheCompBoy is offline  
Reply With Quote
The Following User Says Thank You to TheCompBoy For This Useful Post:
Booocubs (October 22nd, 2011)
Old October 29th, 2011, 12:44 PM   #3 (permalink)
New Member
 
Join Date: Oct 2011
Location: England
Posts: 4
 
Device(s): Asus Transformer, HTC Legend
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not sure if it is possible, but really there isn't any need to. The following code will do exactly what you ask:

Code:
//aspinner is a global Spinner. Doesn't have to be, just so you can access it in the onTouch call

aspinner = (Spinner) findViewById(R.id.spin);
String[] params = new String[]{"SelectA","SelectB","SelectC"};
        ArrayAdapter<String> adapter2 =
            new ArrayAdapter<String> (this,
            android.R.layout.simple_spinner_dropdown_item,params);
        aspinner.setAdapter(adapter2);
        
        //IMPORTANT: This is onTouch and NOT onItemSelected
        aspinner.setOnTouchListener((new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                //Randomly select between 0-2
                Random r = new Random();
                aspinner.setSelection(r.nextInt()%3);
                return true; //returning true will prevent the options popping up
            }
        }));
kegsay is offline  
Reply With Quote
Old December 4th, 2011, 04:05 PM   #4 (permalink)
New Member
 
Olliesshop's Avatar
 
Join Date: Nov 2011
Location: Grosse Pointe, Michigan
Posts: 4
 
Device(s):
Thanks: 3
Thanked 0 Times in 0 Posts
Default

I installed Java SE for my Windows 64 bit machine, but I can't find the program. Does it only run with linked up with the Compiler and/or Android? I can go to the DOS command and type in "java" and get whole lot of "Options" is that what's supposed to happen or is the supposed to be a "regular program" that opens up? Sorry for the Newbie question, I'm just starting out, as of yesterday ...

Thanks for any help/guidance anyone can lend !!!


Tim
Olliesshop is offline  
Reply With Quote
Old December 4th, 2011, 11:55 PM   #5 (permalink)
Premium Member
 
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 193
 
Device(s): Galaxy Nexus GSM
Thanks: 2
Thanked 37 Times in 33 Posts
Default

Quote:
Originally Posted by Olliesshop View Post
I installed Java SE for my Windows 64 bit machine, but I can't find the program. Does it only run with linked up with the Compiler and/or Android? I can go to the DOS command and type in "java" and get whole lot of "Options" is that what's supposed to happen or is the supposed to be a "regular program" that opens up? Sorry for the Newbie question, I'm just starting out, as of yesterday ...

Thanks for any help/guidance anyone can lend !!!


Tim
Hi Tim,

What you've installed is the Java Runtime Environment for Windows. This is a program which is designed to run other compiled Java programs on Windows. Getting a list of options is the correct behaviour when you run "java" from the command prompt.

If you want to develop Android apps, you will need the Android Software Development Kit (SDK). Also you will need an Integrated Development Environment (IDE) to code Java in. Eclipse is the most common (if not recommended) IDE for Android development. After you install Eclipse, you'll need the Android Development Tools (ADT) plugin to integrate Eclipse with the Android SDK.

Finally you'll need to add the SDK components for versions of Android you want to code for the and setup an Android Virtual Device (AVD) to test on.

This isn't something you want to do solo if you're new to programming. I strongly recommend getting some books. Start with books on Java programming. Then progress to books specially on Android programming.
jiminaus is offline  
Last edited by jiminaus; December 4th, 2011 at 11:58 PM.
Reply With Quote
The Following User Says Thank You to jiminaus For This Useful Post:
Olliesshop (December 5th, 2011)
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development > Developer 101 User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 08:09 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo