I'm very new to coding and have searched everywhere but havent been able to figure this one out.
Im trying to create a Lap Time Leader Board for various tracks in a video game guide. The user needs to be able to Click on the track name and then inside of the new layout "Create" a new time...that needs to allow him to imput the Car and the time it did on this track, then it needs to either sort itself or be manually sortable so that the times are in order from fastest to slowest. While i can build the layout easily i get stumped there.
How can i make it so that when the user clicks "Create New Time" the code gives him the spaces for time and car model.
How can i make sure it saves the correct info with SharedPreferences since each time will need to be saved differently (i think this has to do with the name and then ++ but i could be wrong)
How can i make it sort itself or be sortable for the user.
Can someone show me some sample code that does this? I dont know much of anything about SQL and would prefer not to use it if i can avoid it.
Im sorry this is such a noob set of questions but this after trying the notepad tutorial on AD and numerous video and book tutorials i havent found what i need to make this a reality.
You can always use a the Dialog class to create a pop up dialog to allow the user to input the information you are looking for. Sorry that you wish to not use SQL
Shared Preferences isn't such a good idea because you will have to do a lot more work to code your desired affect. A datatbase with simple Relations(tables) will suit your needs as opposed to Shared Preferences where you'd have to get creative to have the same data structure. Such as an ArrayList of BasicNameValuePairs, that could be a head ache. Database is the way to go, you can do everything you need if it's properly set up.
Sorting is quite easy in Java as you could always use the Collections class and implement the Comparable interface to compare your lap times to each other and sort them by total time. For a display such as that you would want to look into a TableLayout in Android XML. Don't worry so much about that, the Eclipse IDE will let you easily create and populate it. This would involve loading your laptimes from your database into a List and sorting them by time. It's a bit tricky but easy once you understand the Comparable interface and Collections if you need it.
If you need more insight post a comment, just wanted to share some ideas on how I would approach it.
Related
I have a profile page as a music curator account, where it shows the score for various parameters there. The most relevant one, monthly listeners, is easily inferred (just a simple excel that I've compiled with the values found on the page), but not shown.
Even though I can constantly calculate it (approximately, because the page might not be consistently updated or might have some flawed calculations), I'm still trying to find a way to have that monthly listeners value updated constantly, and seen as a graph over time.
I was wondering if it's best to do it on android, windows or any other way, to simplify for a complete noob like me, any coding process that i might have to do.
I've only had a little experience in Arduino, so even the basics as to what language to use or the code neccesary for this are foreign to me, but I'm quite interested in learning more about it.
Any help is appreciated, thanks!
I'm making a relatively simple text-based RPG Android game. I reckon it would be a good idea to allow players to save their game and load it later using a single slot (so it's more like a save/continue thing). I think I'd need to save the player's name, inventory items, and of course all decisions so far that made an impact on the game.
What is the best way to do this? I suppose the name and choices could be saved as variables somewhere, somehow, to be loaded into the game later. Inventory might be slightly trickier. I have been at Android development for some time now but never had to save anything like this before.
Depending on your choice of programming language and any software you might be using will depend on what is easiest for you.
Typically for any information saving like what you are doing I use ini files. It may be in your better interests to look into that.
Any more specific help you need I am more than happy to help.
I've got a question more about a strategy to use in order to implement the following requirement.
I need to develop a functionality where a user can perform some actions in the application like posting photos, commenting on photos etc. Every of this actions should leave a log somewhere and after entering one of the screens in my app, all the logs should be visible chronologically (the latest first). I've used a TreeSet sorted by item date and it works pretty fine. The problem is to keep this data persistently so that there's a never ending history of logs. I'm reluctant to migrate my code to SQLite unless it's necessary.. I like quite a lot my TreeSet structure thanks to its methods I managed to keep the logic simple. The problem starts when I'm to save this object across different launches of my app....
Has any one any idea how to solve it? Maybe TreeSet is a wrong decision though?
Putting the Logs in SQLite isn't a bad idea. Your other options is to put them in a file, and keep writing to it. You could then write a class to handle sorting it which shouldn't be too bad. The added benefit of using SQLite would be that sorting by Date would be a breeze. But then then exporting it would require the extra work, while having it already in a file makes it easy. So its really just a preference.
My project is a visitor app for a University, that basically displays places and events on a map, and allows the users to interact with one another by making posts with advice/recommendations/questions and so on.
So far I've been trying out bits of code seperately (lists, tabs, the basics), following the android tutorials and trying things for myself. My problem is that I'm not sure how to combine all the bits of code into one project.
I know that I need to make a database, and a map (using OSM rather than google).
The database will store information on places, events, and posts that users have made. With co-ordinate information because they need to go on the map. This information is also displayed in seperate tabs - e.g. a list of places.
My problem is that I don't know how this will all fit together.
Will I need seperate classes for the database, populating the lists, and displaying on the map? Or can they all be in a single class?
I'm a little hazy on how the classes and activities are going to communicate, too. At the moment I'm thinking the database object is going to get passed to the listviews and mapview, which then take and display some of the information?
Any advice on how to cobble these elements together would be much appreciated. :D
I think I will need to subclass SQLiteOpenHelper for my database, so it'll need to be its own class?
I'm thinking of using OSMdroid for the map, which I'm not sure how to do yet.
And everything needs to be inside a tabview.
Welcome to StackOverflow!
Your question is very vague and broad, and likely to get closed as "not a real question" - I suggest you take problems one by one and ask specific questions as you go along and run into problems. Try to think about your problem in these terms: what's the minimal thing I need to get it to do the thing I want. Keep in mind that ANYTHING you want to do is possible, the main question to ask yourself is: what do you want your application to do exactly? Think about the number of different screens (activities), and how they would communicate to each other (when you click XXX, that will lead you to YYY, and so on). One advice: start simple, it's very easy to get buried in too much complexity, especially since it's your first project. It can quickly become very complex, even with a simple concept.
As you didn't specify your level of expertise in coding, it's difficult to give precise advices: but coding an android application is not very different from a "regular" application, with a web or Swing or C# user interface. So I would advise you to learn about OO programming in general, things like composition, inheritance, encapsulation, dependency injection, unit-testing, etc.
Then start writing a base Activity for your main view, write its layout, and add views and graphical elements to it. Then add the listener code for your widgets, that will generate Intents to other Activity.
Then add a DatabaseHelper when you want to save stuff in a database (that can come later, to begin with, you can just "stub" the interactions to a database, by writing what you would save to db on screen using Toast for example).
All objects can be injected into other objects by passing a reference to them, either at construction time or through setters.
Sorry not to be more precise, as I said it's a very vague question.
im working on a simple Android app, it is much like any other simple Database app. I have 4 EditText fields where the user inputs 4 different small pieces of text. I want this text to be inserted in to my Database table in the corrects rows for my columns. I am not really sure how to go about doing this. I know onClickListener needs to be used but not sure how to use it.
What you are looking for is the glue to make it work, as you have a storage ( your database ) and the user interface. But, as you pointed out just right, your onClick actions, or more widely spoken, your whole user-interaction needs to be filled with action.
I won't give you a specific advice here as I think you should read a bit about the Model-View-Controller Pattern here, as well as about how Android handles all that stuff. A good entrypoint for gaining knowledge is, as always, Wikipedia.
Don't get me wrong, I don't mean to offend you by not answering the specific question: I just think it's more valuable for you to first learn the basics required for building great apps instead of reading a step-by-step manual!
On my phone right now, but you are correct about setting up an onClick method for, let's just say, a Submit button.
I would look at the Developers Guide on the SQLiteDatabase on ways to insert values by executing a SQL statement or check into using ContentValues to insert values when the button's pressed, both could help you out.
Also, with a fair share of knowledge on databases the Developer Guide should be all you need, but if you need further help search for related questions.
NOTE
A good practice is getting used to debugging your code using LogCat. It helps when things go astray, especially when working with databases.
Tne Notepad Tutorial in the Android Developer Documentation takes you through creating an application which stores data from fields in an SQLite database.
You could work through this, or if you didn't want to do that it would be a good source of sample code.