In general, I learn from the book "Head First Programming for Android," why on it? And because it is new, and hoped that I would avoid many troubles with "outdated" methods, libraries, etc. But it was not there, according to the book I need to create a ListActivity (I need a layout with a list of drinks), but as I understand it, it is already outdated, since Now there are many other activities there and Master / Detail Flow is more suitable for them, but it creates a lot of activities and layouts that doesn’t fit into the task. Tell me what to do in this case?

All my projects are created with the expansion of the appcompatactivity class, and in my book just an Activity, is this something related to updates? Can anyone tell you more about this?

    4 answers 4

    Let's start with the fact that you most likely began to learn Java not from the fact that you immediately started writing GUF in JavaFX and organizing client-server interaction, but from the very foundations and simplest examples in the console. When learning to develop Android, you should do the same - to do the simplest examples, gradually complicating the tasks. In fact, the Android framework is a separate eco-system that only uses the Java language to write code, and all this requires a separate learning from scratch.

    I would advise you to study according to the book from BigNerdRanch: B. Hardy - "Android. Programming for Professionals" - 2015 (2nd edition) - this is probably the only worthy book in Russian for a beginner. The training is based on the fact that a specific task is put (some kind of application) and consistently, step by step, with detailed explanations, this task is being implemented. As a result, you write a real working application (there are five of them, if memory serves me, the source code of all applications are available on GitHub and are easily found by name) and you will even understand how to do it yourself. Also, this book will give you a holistic view of the application's device and the interaction of its parts, unlike reference books or lessons on the Internet, which provides scattered information about individual elements, leaving yourself to think about how to combine all this into a working and not frightening the rest who see the code, the application :) With a little zeal, you can find a free electronic copy of this book.

    About obsolete classes and or heirs. The fact that you hardly have to use ListActivity in real-world development, regardless of its obsolescence, since it is the least flexible in the implementation of the list, we will omit here.
    The point is: the base class of the screen of the Android application is the Activity class. Using only this class you can certainly implement all the necessary functionality. The classes ListActivity from the basic Activity only add some functionality, for example, the ListActivity implements the listener and simplifies the connection of the markup, basically it is done in the usual activation in a few lines of code. As for AppCompatActivity , it was created in order to support Material Design on devices with API <21 (up to Android 5.0, where this design is by default) along with the AppCompat support library and provide ActionBar interaction with this support library. I do not think that design delights are the primary task at the beginning of training, the main thing for you is to learn how to work with the framework, you will always have time to decorate. It is also worth noting that if you do not intend to distribute your lessons, then there is no need for backward compatibility.
    When you start learning, you should not pay attention to the "obsolescence" of information or classes - the principles in the database remain unchanged and the "new" classes do not carry anything cardinally new. On the contrary, an understanding of working with "obsolete" classes will facilitate the use of "new" ones, since you only need to understand what (and why) has been added. In the case of AppCompatActivity generally possible, with some minor reservations, to consider it as an Activity , that is, to use it equally.

    Thus, in training projects you can with full confidence use the Activity class, ListActivity and any other class that is required to understand the task, without paying attention to its obsolescence. When you understand the principles of working with the framework enough to write your own application, you can easily determine exactly what type of activation you need for each individual screen, you should not bother now. If you are confused by the default creation of activit, then simply delete the first nine letters (leaving the extends Activity ) and change the application theme from AppCompat to any of Holo, or do not pay attention to it at all - AppCompatActivity naturally implements all the basic methods of the Activity and to work An example of this will not affect, as a rule.

    As for templates, the only template that should be used is Blank Activity, for which the rest remains a secret with seven seals :), a beginner cannot master them due to extreme congestion, an experienced person implements everything independently, as he needs for a specific task, it is easier than Adapt someone else's workpiece to your decision. All these templates are extremely redundant and unnecessarily confusing.

    About the level of knowledge of Java. Possession of basic language capabilities at a good level is enough for writing a full-fledged application. The most relevant knowledge of the framework itself, its classes, the structure of applications, interaction with the system, the principles of layout of models and so on. In particular, the life cycle causes many misunderstandings at the beginning.

    Google has created a very good portal Android developer , which includes both a complete description of the API, and many guides, examples and instructions. In addition, here you will always get the most up-to-date information, in particular, on the differences between the AppCompatActivity and the basic Activity (a brief description and which methods were added to the inherited and by the way, pay attention to the inheritance chain). A nice bonus is that the portal is actively being translated into Russian and many articles can be read in their native language. I advise you to study it very carefully after reading the book above and gaining an initial understanding of the principles of development under this framework. You can start from here

    Well, there is a huge amount of ready-made answers, as well as people who are always ready to answer a good new question.

    PS: if some moments are not clear enough, write in the comments, add the answer.

    • > change the theme of the application from AppCompat, to any of the Holo, you can learn more about it? - Ivan
    • one
      @Ivan in /res/values/styles.xml write something like: <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> : <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> or what topic you like. All other styles can be deleted there - pavlofff
    1. Yes, your book is already out of date in terms of activation. Only a professional can use the studio's default projects - there are too many nuances and it will be extremely difficult for you to somehow change them so that they do not stop working. Your path is completely empty. And in her already create.

    2. Most now use AppCompatActivity because of its backward compatibility. In many details and nuances, the Activity code will not work for AppCompatActivity .

    3. It depends on what you mean by "simple applications". You can list the array on the screen. But your camera or client to the site ... You can, but you will know all the circles of hell and gather here a lot of reputation for dozens of questions. If the questions are qualitative and in the case.

    • 1) I drew attention to this because the book says "List activity defines its layout at the program level, so you do not have to create or maintain XML markup," and also "You do not need to implement your own listener." - Ivan
    • @Ivan, this is convenient to use only if you understand how it works inside. It is likely that you will not stumble upon some nuances, but if you stumble, then it will be very difficult to figure out why something is “not working”. So I would not advise you to use them now. - Yuriy SPb ♦
    • What I mean is that this “ListActivivity” layout defines all this. That is, in my case, it is easier to write an empty layout and something on the level: 3 buttons full screen with transferring an intent for each instead of a list? I just do not quite understand. PS And if it's not a secret how you studied androyd, I understand that you are not a novice, it is always interesting to find out where the pros come from. - Ivan
    • @Ivan, well, you can try, but, like, there is no ListActivity class that extends AppCompatActivity . Those. You will initially work-learn on the currently not very popular API. Transition, in a consequence on modern versions can be hard. And I learned Android and read one book of some kind. Those. Invented a task for myself and brought it to release on my own. - Yuriy SPb ♦

    The book with the book "Head First Programming for Android" is not by hearsay. I use it myself when learning. Books in this series are different from others in the style of presentation of the material and it is captivating for many. I was glad when the 2016 edition came out as the 2011 edition is very outdated. But I was surprised to find that this publication sometimes contains a description of obsolete methods. This does not mean that all books should be thrown away)), on the contrary, it is worth using them. And if the android studio "finds" that you are using an outdated method, it will tell you this and sometimes even offer options. And your task will be to figure out how to solve the problem with the help of new methods .. here no book will help ... only Google, and the community. At the beginning, of course, it will be difficult to write your project, so you can simply type simple examples from books, they will work. At the same time you get comfortable in the Android Studio. And then come up with a project and implement it on the sly. Believe you will encounter such problems that sometimes you cannot find it in any book)) .. But in any case you will look for an answer in them too ..

      I will answer to 3. (Since the novice himself is essentially).

      You can try to write something like simple utilities (Flashlight, etc.). You can make a simple game in the style of Guess the number "and so on.

      And yes, it would be interesting to bring you into your contacts and chat.