Android N Developer Course: D2

Day 5 of 100 days of code.

Learned about Toast today. I think its cute they call it toast because it pops up at the bottom of the screen like toast does out of the toaster.

Toast can only be Long or Short: meaning it will show up at the bottom of the screen for a short or long time. You can also use the variableName.getText().toString() to retrieve what the user entered and display it to the bottom of the screen as well as concatenate any message you want to go along with it. In this case, I added “Hi there, ” so it would display before the name retrieved.

I made a small toast program that has a TextView, a PlainText spot to enter your name, and a button that says “Click me!”.

In the MainActivity, I created an EditText variable and typecasted so the program can find it in the Resources. Here is the code to create this program and the result below!

Overall, I thought this was a neat little bit. I remember watching this video like a year ago and I didn’t think I was ever going to understand it. Well, LOOK AT ME NOW! 🙂

Android N Developer Course: D1

Days 3 and 4 of 100 days of code.

What I’ve Learned:

I had a problem getting my project set up and kept getting the error “Add Google Maven Repository and Sync Project”. The solution to this was to go into the Gradle Project: Build files, find “allprojects” and inside of “repositories” add google() and sync. This error was realized in the MainActivity, my class file for the “import android.support.v7.app.AppCompatActivity;” was read and the AppCompatActivity was red. So, if you ever have this problem.. this solves it. I was trying to run a version of Android that was too old since I am working on the Android N Developer course and had to update it to SDK version 28 and it required the Maven repository.

If you are struggling with getting layout to work in the activitymain.xml, check one of two things. First, go into your component tree and see if you have ConstraintLayout or RelativeLayout. RelativeLayout is a lot easier to work with since you can drag and drop the components onto the screen. Right click ConstraintLayout and “convert view”.

Second, if you ARE using RelativeLayout and they keep popping to the top left corner, go to the top left of your design screen and you will see a tiny little magnet. Click this to turn autoconnect on/off.

Something interesting I found out is 1 dp is roughly 1/60th of an inch. So 160dp is about 1″ on any Android Screen. Good to know for design!

If you are working with TextView and trying to retrieve the text from it by clicking a button, you will create a function that is called when you click the button. You will declare a variable of EditText and typecast EditText to the findViewById (since find VIEW is obviously looking for a view). “R” is for resources and then you will find the ID you entered for the component in the xml file. The button you created on the screen will also need an onClick function saved to it in the XML. You can use Log.i which takes a String tag and String msg parameter. I used the tag as “Info” and used the ID and getText().toString() function to return what it retrieved and convert it to string to display to the log. Code below to explain!

Find this helpful? Connect with me to get these kind of tips everyday!

Thank you for checking my post out.

Why Read My Blog?

If you’re reading this, chances are you are in the same boat as I am: learning to code and finding your way. Most likely, you’re interested in other things and maybe you share some of the same passions as me.

I am in my last year of my BS in Information Technology with a specialization in Software Development. I have worked with HTML, CSS, JavaScript, Java, JavaFX, FXML, XML, Kotlin, and have a passion for mobile applications.

I am also interested in health and fitness, meal prepping, nutrition, helping women in technology, sharing knowledge, reading self-help books, self-care, playing piano, and advocating for others struggling with addictions and helping them overcome it.

The main focus of this blog is just to jot down all the little tips and tricks I learn along the way while coding and also post what I am working on to Twitter. I think that those things need to be shared with others (and having a log of those things will also help me remember how I did something!). How many times have you encountered an error or worked through a problem only to encounter it again and say, “I did this before and I don’t remember how to do it now! ARGH!”. Well, I have done that more times than I want to admit so this will be a collective journal that hopefully someone other than just myself will get use out of!

I would love to connect with other tech women and share experiences and learn from each other. I think that education is a social endeavor and the more we can communicate and learn from each other, the faster it will help all of us advance.

I am starting with the 100daysofcode challenge and will be updating this regularly with my progress. If you are doing the same challenge or want to learn more about it, connect with me and we can work through it together! I love accountability partners.