How to create a scoreboard in android studio? - java

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.

Related

Proper way to to show chords and lyrics in Android app using a textview

I have made a simple Kotlin app which is used to see lyrics and chords together.
I made a textview and set it as per requirements, but the problem is that I could not show chords in the lyrics properly.
This is the current status of my app, while this is an example of what I'm trying to achieve.
In the first image, I can edit the content but the ending result is not good.
In the second image, which is taken from another app, the ending result is nice, and every chord is clickable too.
How can I achieve the same in Kotlin or in Java? How can I make it clickable for a single letter within a textview?
How to put chords in proper way?
Please help me.

Image Handling in android

I'm new to android and I'm stuck. I want to create an app (Picture Quiz) in which an image shown up with specific name under it in a textview. User will choose one answer and new image and its name comes, and they continously keep on coming until the user chooses the wrong answer. Then it will start again but this time images and their names should be shuffled.
I don't know where to put all these images (150 of them) either in drawables or somewhere else. How can i get and show both image and name using one ID and how can i shuffle them. Will i needed sqlite database?
Note: Sorry for lack of data and presentation. I didn't started it yet because i did not found any solutions yet.
one of the best way is
1.
store all images in drawable
2.
Make POJO file which contains all three id, path (R.drawable.image1), name
3.
use Arraylist to insert all data
4.
use Random to shuffle
sure, it's working, will get back further for more.

How do I pass integers?

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

Looking for a way to save game data in my text based game in android studio (java)

I've scoured for the answer for this. I have a simple text based game. I make a choice with a radio button, and confirm it with a button click. I've set the game to save for when I change to landscape from portrait view.
But I cannot for the life of me find how to save the game when the back button is pressed.
I'd like to have a simple menu on the title screen with three buttons, one of them being "Continue" which would restore the game's saved settings. And obviously, one in the action menu I already have set up which would reset all the game data.
I've tried sharedPreferences etc. if someone can tell me the way to save the game data by using SQL so no user can mess with the data, that'd be better.
Thank you in advance for you help.
on edit I realized my question is not specific enough. I am trying to retain the state of a TextView which I am modifying with user choices, thus changing the text. Every time the app is restarted, the first text loads.
It kind of depends on how much information you want to save, but if it's very little I'd look in to shared preferences which saves key value pares. If it contains a bit more, you should look in to SQLLite which is just a database for your app on the device.
Further reading:
SharedPreferences:
https://developer.android.com/training/basics/data-storage/shared-preferences.html
SQLLite:
https://developer.android.com/training/basics/data-storage/databases.html
Have you tried serialization? Put the informations in a file, like a text file, then simply un-serialize it and take back the informations. You can always encrypt it if you don't want anyone to change the datas, like a real game save file.

Android - Creating a Basketball Statistics screen

I'm currently working on an android basketball stat tracking application.
I am using the android SDK and developing it on eclipse.
I'm to the point where we are going to need a stats screen for the game that is currently active. I need to pull stats from the game that is currently running that is outputting stats into a stat table. We are using SQLite as our database to store everything.
My problem is that I know how I can pull and count the different stats, and how to output them. But I'm thinking there is an easier way to do what I'm attempting to do.
For the stat screen activity, this is what we currently have.
Don't mind the big zero in the top left, that's just a formatting issue. Don't mind the warnings either, that's because I didn't make string values for these yet.
So every single zero is its own TextView, and if a team has 20 players, that is 180 TextViews I have to populate with different numbers.
I have thought of different ways I could format the TextView ID's so I would only have to run a different code depending on the player's # for each of the 8 stats.
But in the end, I'm still using 180 different TextViews.
Is this the only way I could do something like this?
You should use a ListView with a custom View and an Adapter, refer to this
http://developer.android.com/reference/android/widget/Adapter.html
A Listview, because you can have 2 or 40 players.
a Custom View (in XML) so you can customize the fields / imageView / others
the Adapter "fills" the Custom View and put into the ListView
http://www.piwai.info/android-adapter-good-practices/

Categories

Resources