📜 ⬆️ ⬇️

Yummy when developing Android applications in Eclipse


Everything is already in the know about the release of Android 4.0 Ice Cream Sandwich. At the same time, the SDK and other Android development files were updated, including the ADT Plugin for Eclipse . I hope, on Habré there will be articles about innovations in the 14th version of Android Development Tools. I will tell only about one new opportunity that I personally lacked.


To understand what will be discussed, it is necessary to make a small digression. When developing applications for Android phones, XML files are very actively used. But, the way of writing in these files is not always perfect, especially if the file is generated by the system itself or is not written by a very neat programmer. Here is one example of such a file:


')
If you look closely at the code, we see that all the attributes are written in one line. Reading this code is very difficult.

Fortunately, Eclipse allows you to quickly format such code, though not everyone knows about this feature. In the Source menu there is a Format item (or Ctrl + Shift + F). When using this command, the code looks much better (found in one of the projects).



But still, I was annoyed by some randomness in the order of attributes followed. When I write the code myself, I try to adhere to some rules - the first attribute is the identifier, the height and width attributes are nearby, and so on.

It turned out that many programmers adhere to this approach. And now these rules have become the standard in Android. After I downloaded the new Android Development Tools and installed it on Eclipse, I launched the same project, the screenshot of which was higher, and again used the command Source | Format . The formatting result is below:



Please note that the identifier is the first, the other attributes are also grouped together.

Now the good news is that all new projects that you will create in Eclipse with ADT v.14.0.0 installed will by default use new formatting rules.
The setting itself is in the Windows section | Preferences | Android | Editors



In this dialog box, the first checkbox of Format XML files ... should be checked, and the first switch should be selected for the way of sorting Logical attributes (first id, then style, markup attributes, other attributes alphabetically).

For the first time I read about the upcoming changes in the official blog of Android developers. Those interested could download the experimental version of ADT and try out a novelty a few months ago. But I myself do not like to put the beta version, so I was looking forward to the release of the official version. Now, when studying someone else's code, it will be easier to put it in order. For what I express my deep gratitude to the developers!

If you yourself want to learn how to write applications for Android, then I advise you not to postpone intent indefinitely. Believe me, this is not as difficult as it may seem at first glance. I myself started writing programs less than a year ago, not knowing Java. If you have programming experience, for example, C #, then you will not have difficulty understanding the simplest examples. I invite you to visit my page where I collected similar simple examples (do not consider it an advertisement). I tried to select examples from simple to complex in my experience. I hope you will understand. If you feel an interest in the development, you can then expand your horizons on your own and write your own Evil Birds that will conquer the world.

Source: https://habr.com/ru/post/130774/


All Articles