Making a Scouting app in android development

I’m attempting to make a scouting app for my team for the (hopefully) off season and I’m stuck at making a checkbox list to select a driver skill rating (i.e bad, moderate, good, great) in a checkbox list. I can’t figure out how to lay out or program the checks.

P.S. I’m fairly new at this so examples in code would be very appreciated

What program are you using?

android studio ver. 3.6.3

What language are you using?

Do they have to be checkboxes or can it be a switch?

Here’s some things to get you started. If you have any questions about anything specific we can follow up. You did mention a list with checkboxes, so that’s what I’m outlining, but based on your description of what you want to do it sounds like radio buttons might be what you’re really after (RadioButton and RadioGroup).

  1. I’m guessing you started a project already and already have a layout where you want your checkbox list
  2. Open that layout and add a RecyclerView. There should be a “Design” tab at the bottom you can click, and the Palette should be open and you can drag and drop RecyclerView from common. RecyclerView is newer way of doing a ListView (which is in the Legacy part of the Palette). For your purposes a ListView will be fairly similar, if you feel more comfortable with it.
  3. In the Component Tree, make sure your RecyclerView is selected. There should be an Attributes pane open. Drop down “All Attributes” and scroll down to Id. Enter an Id (aka a name to use as a reference in your code). I should note that you can add this all in the xml directly, or do it all from code (bad practice unless you’re intending to obfuscate and secure your views better). So if you find someone else’s xml layout you like, just copy and paste some stuff in.
  4. You got a list (RecyclerView) now how do you tell it to use checkboxes? That should be easy because it’s a common thing right? Well it is and it isn’t. What you need to do next is create another layout. Assuming the project view is open on your left side, at the top it should say “app.” Right click and select New->Android Resource File. Give it a file name and make sure “Resource Type” is Layout. The rest of the defaults are fine.
  5. After adding the Resource it probably dropped you right into the Design view. In the Palette, under Text, scroll down to the bottom and you’ll see a CheckedTextView. Drag and drop that in, and modify the properties to your liking. Make sure an id is added.
  6. Now you’ve gotten the basic layout. You will program your RecyclerView to use this new layout you’ve added for each entry in the list.
  7. You will need classes to handle everything. One thing you will need is an Adapter. This class will handle the RecyclerView state. It should extend RecyclerView.Adapter<Adapter.ViewHolder>. In the this class you will want a List to hold all the items. You will want to override onBindViewHolder and getItemCount and onCreateViewHolder. In onCreateViewHolder you will a LayoutInflater to create a new ViewHolder from the new resource you just created. Each time a new item is created for the list, onCreateViewHolder will be called.
  8. Due to how RecyclerView works, and checks disappearing, I would add another class to the same adapter class that extends RecyclerView.ViewHolder implements View.OnClickListener. This class will have access to your list. This class will hold your CheckedTextView for the item, so give it a function to set the check and text. You can use findViewById to initialize your CheckedTextView. This class will be the object returned from onCreateViewHolder, and the onBindViewHolder will call your function to setup the checkbox.
  9. Now all that’s left is in your Activity where this list is going to reside, using findViewById again to find your RecyclerView, create an Adapter object from your class, and use setAdapter() to assign it, and tell it to add items.

I know you asked for some code examples, but it’s more than a few lines. Hopefully there are enough key words in there to get you started on the right path. If you get stuck at a spot, please don’t hesitate to ask for more help. If you can put your code up on github or someplace to view it, it will be easier to help.

Android development is hard because you have to learn a lot about Android to create nice UIs. I recommend playing around with the graphical editor for layouts as that makes it very easy to drag and drop checkboxes.

This isn’t scouting related, but this layout is basically a settings page. For a simple scouting application, you will probably have a layout similar to this. This is good if you want to edit a bunch of information about a single team.

I want to add to this. For me, RecyclerViews are a useful way to display a list of data. You might want to use this if you are keeping track of 6 different robots and need 6 different check boxes or something duplicated 6 times. Or maybe you want to have a page that contains something 50 times so you can easily mark something for each team.

You can use RecyclerViews for a lot of different things, and for simpler things you likely won’t need a RecyclerView unless you need something duplicated a bunch of times.

Also, for selecting something like bad, moderate, good, great, you might want to use radio buttons or a spinner.

I have some more (scouting unrelated) Android code examples, but they’re in Kotlin. If you find yourself using a RecyclerView, I also have some examples of that as well, although I’m sure for just about anything you can find many examples on the Internet.

Thanks for all of the help guys this really clears things up.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.