Posts

Lesson 2 How to exit your application and add a button, position it on the screen and set localizable caption on it

Image
Another mysterious question I hit was " How do I exit my application? " Surprisingly there was almost no information on that subject. Originally surprising, but not for long. The secret is that normally you don't exit from your application the way you do in other languages like quit() in Python or return 0; in C++. The user just hit back button or hides your application by pressing Android '⭘' button. But what if you need to exit programmatically? Let's add to our newly created application a button (you should view activity_main.xml as shown): First, as shown in "Step 1", drag the button from Palette to the Component Tree. Most likely it will show up at the top left corner of the screen. To position it you need to add Constraints that will become visible in attributes. There are two ways to do that. Notice those wiggly lines going describing the position constraints. The prevent your button from taking all the space along with layout width and heig...

Lesson 1: A couple of things to take care when creating a project

Image
Once Android Studio is installed, most people create a new project in a snap. It's easy. However there are three things to keep in mind in the process, especially if this is one of your first Android projects. First of all, you will be asked to pick the main activity for the project. Just FYI, "activity" is almost always a Google Android architects' code name for a screen. You look at your phone, you see a screen with an application, that screen is "activity". If this is one of your first projects, always pick "No Activity": Why? Because any starting activity is a screen, and all other options you have are essentially templates, an empty activity prefilled with things, you can add later. With time you will learn more about those templates and will be able to pick the right one, but in the beginning you are just betting that you won't have to remove the stuff that the template will put in.  And remember, things in Android applications are always...

This is a blog for engineers who already know a few programming languages and dev environments, but ...

This is a blog for engineers who already know a few programming languages and dev environments, but are trying to get into Android applications development. Just like I did. What I found is that there is a plenty of study materials but they are: 1. Missing simple practical questions. 2. Explain in detail evident trivial things. 3. And explain it really long, often as videos instead of a three lines code sample. Examples? First question a good engineer asks is how to exit from the application. You know. like "quit()" in Python or "return 0" in C/C++. You'd expect a lot of answers… and indeed there are. Google gives 28K+ articles on that only on stack overflow. That is 28K+ developers asked that question, failed and had to ask on stack overflow. And only one link from developer.android.com, which actually does not have the answer. Impressive, isn't it? Don't try to google where your source code is or how to get rid of that com.example namespace, w...