I'm relatively new to Android and wanted to practice using it. How do I pass integers in the app? I wanted to build a little combat game where I have a set skill point of 20 and wanted to pass these points to certain attributes. I don't think I can do it through a TextView since hard coding is bad. So essentially my main question is, do I use it through EditText? If so, how? Below is a picture of what I'm trying to achieve.
Thanks a lot for your time.
https://i.stack.imgur.com/i7PNh.png
I don't understand what do you exactly want, but :
TextView is a widget to display a string (or any value converted to string)
EditText is a widget to enter a value
Related
I have a game where I want to display a scoreboard with the previous highscores. I also want to see these scores even if I re-open the app. Is it possible to display it in a TextView? Also, how am I supposed to save the scores locally?
how am I supposed to save the scores locally?
You would use a database. There are a number of libraries to simplify it, I recommend SugarORM.
Is it possible to display it in a TextView
No. You'll almost always want something more than a single TextView. That said, what to use depends a lot on the layout you want to have.
I wanna start out by saying that im just starting to learn android development(and programming) just so you guys know that im not an expert or anything.
So im creating an app that has 5 fragments. the first one has a spinner, the next 3 have each of them 1 edittext, and the last one has a textview. My problem is, i want to collect the user input from the edittext's and the spinner and use it on a formula that is going to give a result to be shown on the last fragment.
And what i need to know is how do i get the user input from the edittexts and the spinner so i can use them on the formula.
For you guys to have an idea of what im aiming for here is a video that i found: http://www.youtube.com/watch?v=gcap7DUgIHg
(I have done other apps that use a basic layout with the edittexts all on one activity, but i wanted to try with the type of layout you see on the video)
I want my app to work exactly like that one, but instead of using numberpickers i use edittexts and a spinner.
This is probably a lot for anyone to explain, but i have been on this forever and i need to deliver this school project tomorrow. Hopefully anyone can give me a help with this as fast as possible.
I appreciate any help given!
Thank you
Here is the code:
MainActivity- http://snipt.org/BGaf2
ResultFragment- http://snipt.org/BGag2
One of the Fragments(Basically all the same)- http://snipt.org/BGah5
PS: SORRY FOR ALL THE COMMENTED CODE AND THE LONG POST, I COULDNT PUT MORE THEN 2 LINKS BECAUSE OF MY REPUTATION
EDIT: Thanks for the reputation! I can now post more than 2 links
Hey I'm writing a quiz application for android. Some of the questions asked require just true or false, and some you need to pick from 4 possible options. I've implemented an intereface with 4 radiobuttons and got that to work fine.
I was just wondering what the best way would be to adjust the number of radiobuttons depending on the question type? I've added in an extra field in my question object to state the number of possible answer choices, but i'm unsure how to use this in my program. Any pointers would be appreciated!
At the moment i'm using a textswitcher to update the question asked when I click next and was wondering whether I could use an imageswitcher to make the desired change with the radiobuttons?
ADDITIONALLY - I was thinking about how I could update the labels on the radiobuttons to the possible choices instead of simply A, B, C etc. just to make it look nicer.
You can try these 2
http://developer.android.com/reference/android/view/View.html#setVisibility%28int%29
http://developer.android.com/reference/android/widget/TextView.html#setText%28java.lang.CharSequence%29
I would like to create a quiz for my Java GUI.
I'd like it to display a question on one page, then have a next button which takes the user to another page telling them if that question was correct or not, and if it is correct they can move on to the next question (by clicking another next button) and if they got it wrong, have to go back and answer it again. However I have no clue how to do this!!
So far I have a simple GUI with a welcome page and tabs down the side, one of which includes a quiz. Would it be a better idea to create the quiz in Flash or something and then embed it into my Java application? Or just do the whole thing in Java? I'm really new to java so I'm not at all sure what to do, any help would be greatly appreciated!
Thanks
It would be best to use just Java. Consider using CardLayout with your GUI to allow swapping questions, or else you can create and modify key components on the fly such as the text displayed by JLabels and JRadioButtons.
Key though before considering any GUI structures is to first create solid OOPS based non GUI classes to handle your questions. For instance, you may want classes for:
Question class that holds a question String, a List of possible answer Strings, a correct answer String. This class can randomly order the incorrect and correct answers, can have a method for checking if the answer selected is correct.
A Test class that holds a collection of questions, that can present questions in random order, that can hold the score obtained.
A QuestionReaderWriter class that can read and write questions to a text file (you definitely do not want to hard-code the question text).
For this type of app it would be best to use the language you are more familiar with.
Since this is just a simple display this then do that there really is nothing very difficult about it.
Personal, I would lean towards Flash as the flash IDE is drag and drop and an experienced flash guru could make this in a few hours. Flash IDE is geared towards this.
I want to create an AnalogClock that can display a preset time, given as a parameter.
And I want to draw between the background and the hands. I want to paint the area between the minute-hand and location of the hour-hand at a preset future time. This is to let the user see how much time remains for the current activity.
I thought that I could take the AnalogClock object and extend that. However, when I create a new function that is essentially a copy of one of the old ones, I get errors on the com.android.internal.R.styleable.AnalogClock* objects: "com.android.internal.R cannot be resolved"
How can I import these objects? I've read something about declare-styleable, but I cannot figure out how to apply that to my situation. (Sorry, I'm really a Java n00b)
For instance, the internal objects refer to several graphical things, such as dials, hour_hand and minute_hands.
Here's my code: http://pastie.org/713276
Any help is very much appreciated, I am stuck after hours of Google.
Here is an tutorial for creating a custom Analog Clock. Shows some sample code, hope this is at least a start in the right direction.
Set time with custom android AnalogClock from its original class Please have a look at my solution. You can use it to display a custom analog clock in a application and set time that you want in it.