What is my program for android. Programming for Android: how to start creating your programs and games? Opening tools

When changing news, you will receive notifications on E-mail and in LZ.

Already subscribed: 2

How to learn how to create programs on Android? In the first place, you need to master the Java language, the shards of Android programs are written by myself. You have given є different ways: sign up for an offline course, which is expensive and, like on me, marno, plus it’s not handy. You can also turn to a tutor, which is more expensive, so it’s not too awkward, but, honestly, it’s more effective. You can also read a lot of books, search for information on the Internet. And, in my opinion, this way is already an order of magnitude shorter than the front, but it borrows, unfortunately, more than an hour. In principle, I have just learned this way. The main problem, with which I stuck, is the outdated code. The most important articles for Android were written back in 2011-2012. And even though it is still relevant, the part is simply outdated in such a way that, in principle, it is not practiced. They gave again the need to search for fresh information, moreover, it is necessary to know the English language, in order to know the correct version of that chi of another task. This is the problem itself in books, shards from the moment the book was written and until the publication of the book, often go through more than one river, but don’t go and not critically (as if forgivingly I think more), but still seriously invest in actuality.

Therefore, in the best way, I respect the video, relying on the following facts:

  1. The best conquest of the material. Be sure, like the author, write that comment code, run the program, and you can get the result at once. That's why you have once and for all ears, and sir, that I will ask you to master the material equally, for example, with books.
  2. You can marvel, be like a mith. You are not surrounded by a specific date and time for such a seminar in Moscow, You are not tied to those to live there, devine to be held, and then go there. You can marvel at the video course, for sure and be it. You do not need the Internet for this, as, for example, for learning about articles on the Internet.
  3. High swidkіst navchannya. For the sake of what you take away everything and in one place, plus more quickly you will conquer everything.
  4. Budget option. The price of a video course is to take a couple of years from an average tutor, or to take a lesson offline, for which you know a little. Vzagali, programming - these are those that the varto learned in the classrooms.
  5. Big cicavishe. Tse, perhaps, subjectively, but especially I, peven, most people respect for better not to read, but to marvel at myself. For me, for example, video lessons from cicavoye for me, those rich cicavishi for any movie. I think that for the rich of you it's just the same.

The course consists of 16 divisions:

  • Partitioned No. 1. Intro.
    • How are you taking the course correctly?
    • How to install Android Studio that, smut, how to correctly install yoga.
    • How to install an Android emulator so that you do not have the opportunity to install the program on your own devices.
    • After the distribution of the software, you will be ready and equipped with the medium for the distribution of programs on Android.
  • Partitioned No. 2. Fundamentals of Android Programming
    • How to spell the simplest addition Hello World.
    • What is the structure of the project? This is an important lesson, since you know about the recognition of all files and folders in the project.
    • How to run the program on a real smartphone or tablet. You tell me that it is necessary to work on the phone, how to connect it correctly to the computer and how to install the program on the device itself.
    • What is the AndroidManifest.xml file for?
    • Having completed this distribution, you can already create your first programs.
  • Partitioned No. 3. Fundamentals of the program interface.
    • You know what Layout files are and how they can be rewritten.
    • You know how to set the layout of the elements and how to position them on the screen.
    • You learn how to create a simple interface of a coristuvach.
    • You know how to complete the steps (for example, click on the button).
    • You learn how to create rich third-party programs.
    • You learn to practice with resources.
    • Having glanced over this part, you can create well-organized programs, as if actively interacting with the koristuvach.
  • Partitioned No. 4. Layout manager.
    • Learn to practice with different layout managers: LinearLayout, TableLayout, FrameLayout, RelativeLayout, ConstraintLayout, ScrollView, GridLayout.
    • You know how to programmatically create and build layout managers.
    • You will learn how to combine different managers at the same time.
    • After this division, you can create an interface, no matter how foldable.
  • Partitioned No. 5. Components
    • Learn how to select different components: text tags, text fields, buttons, checkboxes, radio buttons, lists, components for selecting a date and hour, callers, split notifications.
    • You know how the lists are created in the program.
    • After this distribution, you can win different components from your appendices. Starting from this moment, You are already creating collapsible projects, to which You know: how the interface is created, how it interacts with the coristuvach and how the information is displayed on the screen.
  • Partitioned No. 6. Menu.
    • How to create a menu, submenu, checkboxes and radio buttons in the menu.
    • As a result of the pressure on the various menu items.
    • After this distribution, you can create and beat the most addictive menus with your appendices.
  • Partitioned No. 7. Dialogue vikna.
    • Like the basic dialogue windows are already being developed in Android and like them.
    • How their dialogue victories are established.
    • How to process the dії koristuvach with a dialogue window
    • Having won this division, You can win with your appendices in various dialogues.
  • Partitioned No. 8. Program design.
    • What are the styles and how they win.
    • What are those and why stinks are so important and efficient.
    • He helped you create different design versions of programs and change the design of all programs with just one click.
  • Partitioned No. 9. Robot for Activity and Service.
    • Yakі є methods zvorotnyh dzvinkіv y Activity.
    • What is the object of Intent and what is it?
    • What kind of Intent-filter can you zastosovuvat.
    • How to transfer data from one Activity to another.
    • What is the service.
    • How to create a service
    • How to show remembrance.
    • This one is diligently important, and after a new one you can create in a right way folding functional programs: with background processes, with an impersonal Activity, like exchanging gifts among yourself.
  • Partitioned No. 10. Fragments.
    • What are the fragments and now the stench is needed.
    • How to exchange data between fragments
    • Yaki є methods of reversal links in fragments.
    • How to choke the sides for help ViewPager.
    • Having completed this section, you can work your programs more efficiently for additional fragments.
  • Partitioned No. 11. Work with multimedia.
    • How to practice from images.
    • How to practice audio.
    • How to practice from the video.
    • What is SoundPool and what is Yogo Vikoristovuvati.
    • After completing this section, you can win in your multimedia programs.
  • Partitioned No. 12. Data protection.
    • Write information to file.
    • Read information from file.
    • Save and take care of the program settings.
    • If you share this, you can work with files in Android, as well as learn how to save money and adjust the service information when you exit the program.
  • Partitioned No. 13. Phone calls and SMS.
    • How to make a call directly from your program.
    • How to send SMS from your program.
    • How to change SMS, what to enter.
    • How to take access to SMS I will attach it to read it.
    • How to practice with contacts at the telephone book I will add.
    • How correctly vimagati allowed access to these functions at the coristuvach, to that behind the locking stench, zrozumіlo, fenced.
    • Having glanced at this section, you can create programs that will interact with telephone functions.
  • Partitioned No. 14. Painting in Android.
    • How the painting starts in Android.
    • How to paint and position the figures.
    • Like a little folding post.
    • What is Matrix-transformation and how їх vikoristovuvat.
    • What is Bitmap?
    • What is Drawable, how to do yoga and vikoristovuvati.
    • How to paint a powerful component (for example, your button).
    • How to animate the components (for example, smooth appearance, appearance, movement, laryngeal toscho).
    • How to create an animation image.
    • After this distribution you can create beautiful and stylish programs.
  • Partitioned No. 15. Work with the Internet.
    • You know how to take data from the URL.
    • You know what JSON is and how to work with it.
    • You can use the parsing of data about current weather for geo-coordinates, take away the API of a third-party service, and display it on the screen.
    • It is also an important part, which will allow you to create programs that interact with the API of any Internet service.
  • Partitioned No. 16. Rich streaming programming in Android.
    • You know how rich streaming programs are created in Android.
    • You know how to win the AsyncTask class and why you need the wine.
    • You know how the whistleblower timer is being created.
    • You know how to set the phone to vibrate and how to set the vibrating template.
    • After this distribution, you can create rich streaming programs in Android. It’s also an important split, shards of processing for a koristuvach, a background service flow, a timer for a return signal, a stopwatch, a yearbook - all this can be practiced in different streams. The first axis of the creation of different flows with different goals and tasks You learn in this division.


Bonusy The course and so wiyshov already ob'emnym, but krіm the very course at once with him You also take away the kilka of non-koshtovny Bonuses. All output code from Bonuses, insanely, is added to the course.

  • Bonus №1 Creation of a widget. Upevneniy, so many of you know what this widget is. But for those who don’t know, I’ll briefly explain what the widget is - it’s a small program that can be found on the working table. There can be, for example, the balance of your bank account, weather reports, a list of references for today. And in this Bonus, which consists of 5 lessons, you will learn:
    • Create widget.
    • Take a lashing like a coristuvach.
    • Improve the pressure on widgets.
    • Update information on the widget.
    • Create complete widgets from scratch on the basis of a weather widget.
  • Bonus #2. OpenGL and 3D painting. More foldable material, but more korisny for quiet, who plans to create graphic programs, for example, games. Tsey Bonus consists of 11 lessons, for which:
    • You get to know OpenGL.
    • You know what a shader is.
    • You know how shapes are drawn in OpenGL.
    • You know how to practice with the OpenGL color.
    • You know how 3D images work.
    • You know how to use the screen in different screen orientations.
    • You know how to practice with the camera.
    • You know how to animate the camera.
    • You know how transformation will take place.
    • You know how to texture an object.
    • See the buttstock of the 3D textured object behind the camera that wraps around.
  • Bonus number 3 Creation of the Vision program. I wrote this addendum for myself, but I vvazhu, scho will be corny for everyone who works a lot at the computer and if you want to save your svіy sіr. The essence of yoga is that, through equal intervals, interrupt the hour of work. For example, 50 minutes at the computer and 10 hours of break. After a skin interval, the phone is guilty of signaling about those that an hour at the computer or an hour of work will break. I guessed, at the functions of the program, the hour can be overwhelmed. Also, this add-on can have some impersonal other nuances implemented: timer drop, dialogue window, timer robot when the program is closed, and a lot more. So the axis of the program, as I myself am especially vicorous and raja її vikoristovuvat і to you, for whom we will create Bonuses with you. The Bonus itself is made up of 10 lessons, which you will learn from:
    • How the head display is created.
    • How the screen is created from the adjustments.
    • How to add a support for the landscape orientation.
    • How do you think about savings and savings?
    • How to fight a birthday.
    • How the timer of the turnaround is created.
    • How to show it is processed in a dialogical way.
    • How to add a vibrating sound and an audio signal.
    • How to use the key to change the timer robot mode.
    • How to fight the timer drop button.

The Android operating system with skin rock is becoming not only an adjunct OS for high-profile coristuvachiv, but also a hard platform for retailers. What do you think: Google is a good idea for developers, offering wide possibilities and tight tools, filling informative documentation.
Until then, do not varto call on the fact that the “green robot” is the leader in the popularity of mobile operating systems. It’s not worth talking about those who, programming under Android, you can reach a wide audience, as you can bring profit every year. Zagalom, Android is a kind of "oasis" for retailers. Therefore, we have prepared for you a special compilation of mov programming, as well as middleware for the development of OS.
Uvaga, little help for newcomers
: programming on Android can be more collapsible or rather monotonous Porada: first look at the text on the back of the documentation, the first below is taken to the right, and even programming on Android will not become a problem for you.

Java - the main feature for the Android retailer

Rozrobki middles: Android Studio (IntelliJ IDEA) , Eclipse + ADT plugin
Pidide for a wide range of
Java is the main language for Android programmers, the language must-have for beginners. The main Android code is written in my own words, so it's easy to understand why it's better to choose my own words. Programs written in Java run in Android behind the help of the ART virtual machine (or Dalvik in Jelly Bean and earlier versions of Android) - an analogue of the Java virtual machine, through Google's own serious ship call from Oracle.


Google at the moment is officially supporting the development of Android Studio, which was chosen based on Intellij IDEA variant JetBrains. Also, do not forget about the report documentation like Google, in which everything is sorted out: from match_parent and wrap_content to constructors, constants and main methods in the JavaHttpConnection class, read about the language.

Besides, don't forget about Eclipse - the most popular medium for Java programmers. With the official ADT plugin like Google, this toolkit will become tight and light in your hands. But the lads from Mountain View have stopped supporting Eclipse since the summer of last year, giving up the money of the fresh Android Studio. It is recommended to vicorate on weak computers.

Required documentation:

C++ - a hard tool in the hands of a master

The main medium of development: Android Studio (version 1.3 and higher), Visual Studio 2015, QtCreator
Pidide for game engines and resource add-ons.
C ++ is not young, but it’s still hard for me to program, as it marked the past fate of its thirty years. We were found guilty in 1985 by the efforts of comrade Bjorn Stroustrup and took the top positions of the most popular programs. "Pluses" give new freedom to diy, enclosing you no longer within the framework of the reasonable.




For all the foundations of Android, a lot of frameworks and development tools for C ++ were created. I would especially like to see widely the Qt and IDE QtCreator, which allow you to expand cross-platform programs for Windows, Windows Phone, Windows RT, iOS, SailfishOS and Android (up to the list of incoming Symbian). In addition, you will manually adopt Tulip's library of containers, algorithms, and templates, which has taken everything best from Java and Android. Well, I'll tell you, you'll accept anonymous different QT-modules for high- and low-level robots from the system. Your pokіrny servant codes itself in the language C ++ and Qt.

The past fate at the Windows conference: The Next Champter was given wide recognition to the popular Visual Studio 2015 development medium. yu OS.

You can't help but guess what the official Android Studio has become to support the NDK. With the help of NDK, you can beat Android OpenGL graphics for an hour. If you need speed and efficiency - choose NDK! This method of development is designed for gaming engines, which means great productivity.

Android development in C or C ++ can be done more simply in Java, but, regardless of those who teach you the freedom of the language and don’t surround you with your croques, because of some specific features, on the other hand, it’s not for nothing C ++ compete with nunchucks (wonderful armor, which, unfortunately, means majestic mastery). Prote development of Android programs in C and C ++ may appear on the right.

Required documentation:

Other movies

Now is the time to tell about other less popular ones, but also movie and frameworks for them. However, for a variety of reasons, you cannot achieve such success as Java and C++.

Corona (LUA Script)


Pidide for creation of igor and simple additions
If for some reason you don't want to learn Java or get into the interface via XML, then you can choose your own IDE. Corona - it's important to do it with a lightweight medium of development, the code must be written in a light LUA (Pascal lovers can appreciate it).

This toolkit will help you with the writing of the simplest 2D mountains, for which there are libraries for 2D objects, sounds, media and a game engine. The games are created from OpenGL, which means high efficiency. Suitable for beginners, maybe you can create your first mobile add-on on Android on your own!


Required documentation:

Adobe PhoneGap (HTML5, JavaScript, CSS)


Pidide for creation of non-resource supplements
If you already know HTML, CSS and JavaScript, you can try PhoneGap as an alternative. Ce IDE allow you to select all the programs, rozroblenі on vyschezgadannyh mov programming and rozmіtki.

The really ready-made programs from PhoneGap are the simplest WebView, which is complemented by JavaScript. For the help of various APIs, you can tweak various functionalities and build them on native add-ons. What's up - the programs are compiled on the server and then available for download on iOS, Android, Windows Phone, Web OS and BlackBerry OS. With such a wide cross-platform, the development of programs can significantly speed up.


Required documentation:

Fuse (JavaScript and UX)


Pidide for creation of both simple and folding programs
When people talk about Android development problems, they often think of Fuse. This tool is one of the best in its kind, and you can present a wide range of possibilities and advantages to the retailer.

The main logic of Fuse-additions will be based on JavaScript - simple and intelligent language with a low entry threshold. The interface foundation is represented by UX-marking - intuitively understood by the skin. Well, the “buns” of the medium allow you to zastosovuvat zmini directly under the hour of the robot programs on your attachment or emulator - like Android Studio 2.0 and more. For the help of Fuse, the development of programs for Android can be awkward and awkward.

Required documentation:

The words "under the veil"

Obviously, we have shown you far from all the tools of development that are currently available. In this article, we would like to explain to you that becoming an Android retailer is not so easy, although it often means diligence and commitment. The world of rozrobki under mobile platforms є vіdkritim for you, but remember: the first step is yours.

What time is it official Android IDE letter Eclipse (as the de facto standard for Java) with the ADT plugin. A few hours later, Java programmers began to gain popularity with an IDE like JetBrains, then a plug-in for Android development appeared for it, and people began to slowly switch to it from Eclipse.

A few more times Google tells you about those who work with Android Studio based on IDEA. The І axis is on the way to another version of Android Studio, and Eclipse will start like a bad dream :)

android studio- Official middleware for Android distribution. In fact, Android Studio is the home of Java IDE IntelliJ IDEA with plugins.

At the moment, there are these options when choosing an IDE for Android:

  1. eclipse. Today's most popular IDE for Java, now hack for Android development not recommended at all.
  2. IntelliJ IDEA. Vіdminna IDE, good for Android.
  3. android studio. Best IDE for Android. The IDEA is reminiscent of dribnitsy, but al t dribnitsy will take and greatly ease our work:) We are on our own.

First of all, you need to check that you have the JDK (Java Development Kit) installed. The same language component for development in Java, and the oskіlki technology for Android is conducted in Java - then for the development of Android tezh.

In a different way, check the boxes "show line numbers" and "show method separators":

The first one is the number of rows and the left hand in the text, the other is the tinkering between methods in the code.

These two options are incredibly important, especially for beginners, and I don’t know why the stink is taken away from the locks.

third, set up auto-completion. For which in "Case sensitive completion" select "None":

Let me explain why. The option for capturing the transfer does not require auto-completion only in that case, as the first letter is typed in the correct case. The None option prompt autocomplete regardless of which register you started dialing the code from.

The standard value of these options, like the past two, called out to me.

Creation of the first project

Well, with the installation and installation of Android Studio, the world has come together, the hour has come to create our first project.

At the head window of Android Studio, click on " Start a new Android Studio project«:

To appear new vikno, in which it is necessary to vikonate a sprig of diy.

For the first one, you need to set the name of the program, the domain of the company (from these two parameters, the name of the package will be created), and the distribution of the project on the disk:

In Android, like Java, the main program identifier is the package name. You have worked with Java before, you know what. Tim, who doesn’t know, I recommend Google, or, for example, the axis.

Then Android Studio asks us which versions of the SDK we want to win. Until we download the "Phone and Tablet" SDK, put the API version 16 instead of 15, which is recommended, the API 15 shards are no longer relevant and should not be wider:

On the next screen, power up, like the components of the program we want to create. Select "Empty Activity":

On the offensive stroke, simply press Finish, without changing anything.

After the completion of this process, you will thank, nareshti, your first project:

Vіn is already quite practical, but to run it, we need an Android emulator.

Android emulator creation

To create an Android emulator, we need Android AVD Manager(AVD = Android Virtual Device). Don't worry, you don't need to put anything else. Just click on the button:

Let's press the button:

And then we'll just hit "Next" once again and, nareshti, "Finish"

Launch Hello World

The hour has come to launch our first project, the creations of android studio!

Press the button on the axis (or Shift-F10):

After which you enter a dialogue, in which you will be asked to choose a device, on which IDE you can run the selection of add-ons:

Place a check mark with the arrow and press "OK". Completing the project, launching the emulator, installing the program on the emulator and launching the program.

On the chain is a deaky hour (that your computer is tighter - it will take less time), shards of the emulator - it’s enough to do it, regardless of the colossal improvements in the rest of the couple of years.

І axis, after 1-10 minutes (after the launch of the emulator, the projects will, of course, be picked up and launched more quickly), you, nareshti, play your Hello World on the screen of the emulator!

That's all for it, but in the coming hour we can see it.

New lessons coming up today! So that you don’t miss anything, subscribe to our

At be-yakіy in the right place is more convenient - tse cob. Often it is important to go into the context, why I got stuck, having developed my first Android add-on. Tsya stattya for quiet, who want a little, but don't know why.

Statya to stick to the whole cycle of the program development. Together we will write a simple game "Chris and Tac Toe" with one screen (in the Android OS it is called Activity).

The moment I know my Java is not guilty of becoming a jumper in the development of Android. So, butts will not have Java-specific designs (because they will be minimised on insoles, if possible). If you write, for example, in PHP and know the basic principles of software development, this article will be the most appropriate for you. For my own part, since I'm not an expert on Java development, I can admit that the resulting code does not claim to be labeled "Better Java Development Practices".

Installing the necessary software utilities

I will list the necessary tools. Їх 3:

  1. IDE with support for Android:
    • Eclipse+ADT plugin
    • IntelliJ IDEA Community Edition
    • Netbeans + nbandroid plugin

Utilities are installed in the prescribed order. There is no way to put all the IDEs on the sensu (hiba yakshcho You see the difficulties with the choice of the best). I'm using IntelliJ IDEA Community Edition, one of the most recent IDEs for Java.

Launching a virtual building

By launching AVD Manager and installing additional packages (SDKs of other versions), you can create a virtual device with the necessary parameters. It is not guilty to lay down difficulties in the interface.

List of outbuildings

Project creation

I can't wait to start working, minimizing preparations, come in, to which the project needs to be created in the IDE, especially if the project is initial and does not apply for production.

Also, File->New Project:

After pressing the F6 button, the project will be taken, compiled and launched on a virtual device.

Project structure

The front screenshot shows the structure of the project. Oskіlki in this article are revisited daily practical goals, less respect for those folders, as we will victorious in the process of work. These are the directories: gene, resі src.

in papacy gene files are found, which are automatically generated during the project compilation time. I cannot change them by hand.

The res folder is used for saving resources, such as pictures, texts (including translations), for locks, layouts (layouts).

src- this folder is more important than most robots, because here files with original texts of our program are saved.

First rows

As soon as the Activity (program screen) is created, the onCreate() method is called. The IDE filled yoga in 2 rows:
super.onCreate(savedInstanceState); setContentView(R.layout.main);
The setContentView method (exactly this.setContentView) sets the xml layout for the flow screen. We gave the xml layouts the name “layout” and the screens “Activity”. Layout at the addendum will be offensive:

For this program, it is ideal to use TableLayout. Id can be assigned to any resource. In this view, the TableLayout is assigned id = main_l. Beyond the help of the findViewById() method, you can access the view:
private TableLayout layout; // purpose of power for the KrestikinolikiActivity class public void onCreate(Bundle savedInstanceState) ( super.onCreate(savedInstanceState); setContentView(R.layout.main); layout = (TableLayout)

Now we need to implement the buildGameField() method. For which it is necessary to generate a field in the view matrix. Tsim will take up the Game class. At the same time, you need to create a Square class for the middle class and a Player class, the objects of which will fill in the middle ones.

Square.java

package com.example; public class Square ( private Player player = null; public void fill(Player player) ( this.player = player; ) public boolean isFilled() ( if (player != null) ( return true; ) return false; ) public Player getPlayer () ( return player; ) )

Player.java

package com.example; public class Player ( private String name; public Player(String name) ( this.name = name; ) public CharSequence getName() ( return (CharSequence) name; ) )

All classes of our programs are found in the folder src.

Game.java

package com.example; public class Game ( /** * field */ private Square field; /** * Constructor * */ public Game() ( field = new Square; squareCount = 0; // filling in the field for (int i = 0, l = field.length;i

Initialization of the Game by the constructor KrestikinolikiActivity.
public KrestikinolikiActivity() ( game = new Game(); game.start(); // will be implemented later)

The wake-up methodGameField() of the KrestikinolikiActivity class. Win dynamically adds rows and columns to the table (game field):
private Button buttons = NewButton; //(....) private void buildGameField() ( Square field = game.getField(); for (int i = 0, lenI = field.length; i
At row 8, an object is created that implements the View.OnClickListener interface. We create attachments of the Listener class. Vіn bude will be seen only from Crossіkіnоlіkіkіtivnostі.
public class Listener implements View.OnClickListener ( private int x = 0; private int y = 0; public Listener(int x, int y) ( this.x = x; this.y = y; ) public void onClick(View view) ( Button button = (Button) view; ) )
Lost realizuvati logic gr.
public class Game ( /** * gravel */ private Player players; /** * field */ private Square field; /** * pinkish square? */ private boolean started; /** * current gravel */ private Player activePlayer ;/** * Respect the number of filled fields */ private int filled;/** * Required fields */ private int squareCount; // Field filling for (int i = 0, l = field.length; i

Appointment help

K. O. suggests that in cross-zero it is vivaying the one that vibrates X or O in the line of the dove, that the dove of the dove is the field vertically, or horizontally, or diagonally. The first thought, as it falls on the thought - you should write a method for skin relaxation. I think that someone has a good idea for the Chain of Responsibility pattern. Significantly interface
package com.example; public interface WinnerCheckerInterface ( public Player checkWinner(); )
Shards of the Game can be used to show the ability to implement this interface. The hour has come to create virtual "linesmen", skins from which we will turn our side. All of them implement the WinnerCheckerInterface interface.

WinnerCheckerHorizontal.java

package com.example; public class WinnerCheckerHorizontal implements WinnerCheckerInterface ( private Game game; public WinnerCheckerHorizontal(Game game) ( this.game = game; ) public Player checkWinner() ( Square field = game.getField(); Player currPlayer; Player lastPlay i = 0, len = field length;

WinnerCheckerVertical.java

package com.example; public class WinnerCheckerVertical implements WinnerCheckerInterface ( private Game game; public WinnerCheckerVertical (Game game) ( this.game = game; ) public Player checkWinner() ( Square field = game.getField(); Player currPlayer; Player lastPlay = i = 0, len = field length;

WinnerCheckerDiagonalLeft.java

package com.example; public class WinnerCheckerDiagonalLeft implements WinnerCheckerInterface ( private Game game; public WinnerCheckerDiagonalLeft(Game game) ( this.game = game; ) public Player checkWinner() ( Square field = game.getField(); Player currPlayer ; 1; for (int i = 0 , len = field.length;i

WinnerCheckerDiagonalRight.java

package com.example; public class WinnerCheckerDiagonalRight implements WinnerCheckerInterface ( private Game game; public WinnerCheckerDiagonalRight(Game game) ( this.game = game; ) public Player checkWinner() ( Square field = game.getField(); Player currPlayer ; 1; for (int i = 0 , len = field.length;i
Proіnіtsіalіzuєmo їх at the Game constructor:
//(....) /** * "Judg" =). After a skin move, the stink is reversed, * what can not be overcome */ private WinnerCheckerInterface winnerCheckers; //(....) public Game() ( //(....) winnerCheckers = new WinnerCheckerInterface; winnerCheckers = new WinnerCheckerHorizontal(this); winnerCheckers = new WinnerCheckerVertical(this); winnerCheckers = new WinnerCheckerDiago winnerCheckers = new WinnerCheckerDiagonalRight (this); //(....) )
Implementation of checkWinner():
public Player checkWinner() ( for (WinnerCheckerInterface winChecker: winnerCheckers) ( Player winner = winChecker.checkWinner(); if (winner != null) ( return winner; ) ) return null; )
Peremozhtsya pereviryaemo after a skin course. Dodamo code for the onClick() method of the Listener class
public void onClick(View view) ( Button button = (Button) view; Game g = game; Player player = g.getCurrentActivePlayer(); if (makeTurn(x, y)) ( button.setText(player.getName()) ; ) Player winner = g.checkWinner(); if (winner != null) ( gameOver(winner); ) if (g.isFieldFilled()) ( // vipadoo, so the field is filled gameOver(); ) )
The gameOver() method has 2 implementations:
private void gameOver(Player player) ( CharSequence text = "Player \"" + player.getName() + "\" won!"; Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); game.reset (); refresh(); ) private void gameOver() ( CharSequence text = "Draw"; Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); game.reset(); refresh(); )
For Java, gameOver(Player player) and gameOver() are different methods. By speeding up Builder's Toast.makeText, you can quickly create and show refresh. refresh() update the field stan:
private void refresh() ( Square field = game.getField(); for (int i = 0, len = field.length; i

Ready! I am sure that this article has helped you to get used to the world of Android OS development. For respect!

Video of the finished program

How does the Android development process work? We see a sprat of basics:

  • In Java files, you describe the logic of the program - those that you want, so that your program will work.
  • In XML files, you can expand the layouts - it looks good.
  • As soon as the program is written, it will be necessary to select a tool to compile all the files and pack them all at once into an .apk file, which can be run on Android devices and/or published on Google Play.
  • All utilities and files, which are used for creating Android programs, are combined in an integrated development environment (IDE). IDE is a program that you can use to edit your files in code, as well as compilation and launch.
  • Eclipse used to be the standard IDE for Android development, but at the same time it replaced the functionality of Android Studio, a product of Google.

You, obviously, you will know more profound processes that go beyond the lashtunkas of the refurbished more crucibles. For example, poked out coristuvachi want to know about the role of the Dalvik virtual machine. For example, the statistics will be redeemed on the basis of resources, for which you may know the Android skin rozrobnik. The first of them is official documentation from Google.

  • Zavantzhimo and install Android Studio.
  • We know about launching and testing programs on attachments and Android emulators.
  • Let's create a simple add-on for Android, which will display Hello World on the screen of a mobile device.

For example, you can get familiar with the basic recommendations to retailers-cobs of the company.

Installing the Android Studio distribution environment

Start reading the documentation and writing the code to find out on which building platform - it's smart enough. And we will soon be safe! However, for the beginning of the work with the Android platform, it is necessary to fix the middle of the development.

It is especially important for newcomers to Android programming not to rush and methodically follow the skin crotch. If you get it right, you may need to fix a small problem with setting up the middleware in the fallback in your system configuration or product version. For whom win the poshukov services. You can especially see the StackOverflow resource.

It is important not to allow, if water stones crossed your end stone - learn how to program Android. Apparently, scho navit professionals іnоdі mаyut nі nі problems z nastuvannyam robochego otochennya. In such moods, it is important to know the command line. If you want to get to know this instrument better, below you should aim at a good entry.

After training in syntax, it's important to learn the idea of ​​a successful programmer, as we won't accept the warning about the pardon file X not found by the residual virus. Such a mind is easily trained by you at the peaks, so you don’t know and joke about the problem.

Go to the side of Android Studio developer.android.com/studio/index.html and find the button to download the remaining version for your platform.

Click on the button of interest and you will be asked to familiarize yourself with the rules of the software product. After a respectful reading (as you always do) and accept the zavantazhennya. Ymovirno, tse trivatime kіlka khvilin. If so, you can install Android Studio in the same way as before any other program. On the other side of the page, there are instructions for installing Mac and Windows.

Now, if you have installed Android Studio, let's run yoga! Open Android Studio. The program asks if you want to import your settings. You start the chips from scratch, just change the other item and continue.

You are to blame for the garni zavantazhuvalny screen in the style of Material Design.

After the end of the adventure, you will spend on the screen of privacy.

Note that since you've hijacked Android Studio, you may not have the latest version. To get rid of problems with the versions above, click on the button Check for updates now and, if necessary, click on all the instructions to check out the remaining version. Sometimes Studio automatically informs you about those that are being updated for an additional screen similar to this one:

At this time, always choose Update and Restart. Miraculous! We successfully ran into the middle of the middle for expansion.

Creation of the first Android project

The hour has come to create the first project. Let's start from a simple one. It is customary for programmers to name the first program Hello World. Let's follow our traditions, and then we'll make some small changes, so that the program wins your name for hospitality. In the world, you can get Yogo on the hook and show it to your friends. Android Studio is a small, powerful tool to help you build your project. Press "New Project" on the start screen:

Say yoga like this. Don't forget to replace "example" in the package name by now, so you can see the front at the bottom of the screen. You can also install a root for the project by specifying a folder on the hard drive

For versions of the SDK that are being developed, pay attention to the "Description" section at the bottom of the dialog window. It is explained to the new one why skin patching is recognized.

Install the minimum required SDK as shown in the screenshot. Do not install the minimum version of Android required to run the program. The choice of which value for your power projects is the chain of balancing the possibilities of the SDK, if you want, that outbuildings, as they will be supported.

To obtain additional information about the API version and its version on the website for Android retailers, there is a special Dashboards page https://developer.android.com/about/dashboards/index.html.

After selecting the version, the screen for selecting the start template appears. You can create a program that already interacts with the google maps api and displays the map. For our test application, we select Empty Activity and press the “Next” button.

І contagion you know the rest of the process of creating programs. First press Finish, respect for deak speech. Here you are stuck with riddles about the main architectural components and be it programs.

  • - tse persha, but not the riddle of the word Activity. In the context of Android, Activity sounds like a "screen" for your addon. The tsey element is already a bug. If Android Studio creates the MainActivity class, it will drop it to the Activity class from the Android SDK. Those who know about object-oriented programming can understand the concept, but for beginners, it basically means that your MainActivity will be the version of the Activity that you want to configure.

  • Layout Name- the layout of what will be shown in the box is assigned to a special Android XML look. You will soon learn how to read and edit files.

Press Finish. An active hour will take the creation of that interest in the project. After one hour, Android Studio will complete the build of your project. Obviously, the project is still empty, but in the new it's all necessary to run on an Android device or an emulator.

If you are interested in the project, you review the layout file in XML format. First, go to Android programming, let's talk about how we can run this program. It's time to say "Hello world!".

Running the program on the emulator

Now it's time to say a few words about the emulator. Android Studio comes with software that builds Android apps for running on new programs, browsing websites, tweaking, and more.

What is possible is Android Virtual Device (AVD) Manager. For bajannyam you can adjust the emulator splice, install the screen resize and the version of the platform for the skin new emulator. This functionality is more expensive, the shards allow the retailers to buy a sprat of attachments for testing programs.

Press the Run button next to the green arrow.

Come early, while the emulator is occupied, and as soon as you are ready, you will be ready for a moment:

My bath! You've made your first add-on for Android!

And so ... Why and how did it work?

In order to start working on changing and adding functions, it is necessary to take into account more knowledge about those who are looking for lashtunks. Take a look at the distribution of the Android Studio project with files and folders on the left side of the screen. You may need to click a small tab on the edge (div. below), as the project explorer is not displayed.

Take a look at the folder structure and double-click on the files to make them appear in the main window. Even though everything looks mysterious, do not boast!

Android project structure: Team

A skin is good team is made up of people who play their roles. You want vikonati robot right? You need the right command. Android projects have a few key elements, and some of them can play a major role:

Java: Professional

Tse part of your code, yak povіdaє for the logic of the program. Your code is located in the src\main\java directory in the main project folder. For learning about Java, you can look at Bruce Eckel's book "Philosophy of Java";

Resources: Artist

It’s not enough just to have Android add-ons, but it can be stylish. Your program will never be seen, as it does not have clear icons and images, well-thought-out layouts and, possibly, smooth animations.

When initializing the folder, delete the following folders:

  • drawable, icons are saved. At the same time, there is no longer a standard program icon to lie there.
  • layout with XML files, like screen designs.
  • menu with XML files of lists of elements, which are displayed on the panel.
  • values ​​with XML files to change the dimensions, colors, string constants and styles.

AndroidManifest.xml: Bos

This XML-file informs your system about the software before the software is installed and the program can replace its version and icon. Manifesto also send information about all Activities to the addendum. Do you need a job, how do you get your supplement? Spochatku talk with the boss.

Making changes

Navigate to res/values/strings.xml and double click on the file. If you view the file, you will see two rows of resources in XML.

These resources are hacked in different areas, but you can also manually copy the entire text, which is hacked to your addendum in one file. If you need to translate yoga, or if your marketing colleague asks you to remove all requests, it’s easy to make all the changes.

Change the hello_world row, which program displays on the screen. Change її instead of a special one, for example, vikoristovyte well im'ya. Viide schos on kshtalt:

Matt is learning Android!

Press the Run button. The program is to be restarted and you will receive a personal message:

We love you - you have built the first project and have learned how to edit the output code. The first crack in Android programming is broken. Good luck on this difficult, even more cirque way! If you need professional software development for Android, go to Infoshell facsimiles.