-
Start Android Studio
-
Select checkout from version control and choose git
-
Paste in the URL:
https://github.com/RobRoseKnows/hackumbc-tutorial.git -
Press clone and select YES
-
Import project from external model
-
Select default gradle wrapper and hit OK
-
Wait for the project to build
-
Make sure both are selected and hit OK
-
Setup Frameworks will pop up and Hit OK
- Go to your device's About screen and tap the build number a bunch of times.
- You are now should have the developer menu available, open it and enable USB Debugging
- Plug in your device to your computer using a Micro-USB cable
- If it asks for authorization, click yes.
- Open the Android Virtual Device Manager (AVD)
- Either create a new AVD with an API version of at least 19
- Do not choose an Intel processor.
- Open the virtual device and leave it open. That saves time.
- Designed the
activity_main.xmlfile.- Created a TextView with the ID
gpa_text - Created a ListView with the ID
class_list - Created a Button with the ID
create_button
- Created a TextView with the ID
- It's a relative layout, you can see some of the examples of ways to organize them.
- Added String resources.
- The
current_gpastring resource has formatting markup.
- The
- I am not an expert on the inner workings of Android but here's what I do know:
- The Android APK contains a bunch of things that make up an Android app.
- I'm going to refer you to Wikipedia
- Contains:
META-INF: the manifest, and the certificates and hasheslib: Processor-specific coderes: Contains the resources not compiled intoresources.arscassets: contains things like images, icons, etc.AndroidManifest.xml: meta-data for the Android app.classes.dex: Everything compiled togetherresources.arsc: Resources pre-compiled
- All this compilation happens when the app is opened for the first time.
- There's one important file called
R.javathat contains references to where the program can find all the views, resources, etc.
- A View is an Object that is the super class of all things drawable in Android
- Some subclasses of Views are:
- Even Layouts are views, they are sub classes of the subclass ViewGroup.
- Layouts are ViewGroups, they hold a bunch of view in a nested way.
- You define layouts in XML files, it's easier than the design mode once you get the hang of it
- If you are familiar with AWT or Swing, many of the same layouts you find there you can find in Android.
- Layouts Include:
- Those are just a few of them.
- Views wouldn't be very helpful if we weren't able to manipulate them in code.
- So we need to use
findViewById()to get the View Object. findViewById()returns a View object though, we need to cast it to the type we wantR.javagives us access to all the ids
gpaTextView = (TextView) findViewById(R.id.gpa_text);
classListView = (ListView) findViewById(R.id.lecture_list);
addClassButton = (Button) findViewById(R.id.create_button);
- We create a new XML file to create a View to hold each lecture.
- Now we're going to populate the ListView with some of our data.
- We have data already in the form of the
exampleClassesArrayandexampleClassesList. - We're going to put this into the
classListViewListView. - We need to use an ArrayAdapter
- But first we need a View.
ArrayAdapter<String> itemsAdapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items);