Bubble Android Notes

Source: Internet
Author: User

Android Note

Written by Mr.bubbles

  1. The first thing to configure JDK Eclispe is not to say much.
  2. Eclispe is mainly used in XML and Java two languages, XML processing presentation layer, is the ability to layout a page, add elements, is to implement the UI and the different UI of the surface of the foundation, that is, no logical consideration.

    Java is a concrete logical design, so each XML corresponds to a controlled Java file.

  3. XML language is the description and nesting of elements, labeled elements, property syntax <element property= "(what is it should be)", End </element> and/> Play the same role. At compile time, when the element is edited, the direct typing > will automatically get ></element>, which is very convenient and practical, and straightforward and easy to understand.
  4. Start by building a basic single UI from the XML language, and familiarize yourself with XML from a linear layout (LinearLayout) relative layout (relativelayout). (These two are viewgroup subclasses, inheriting ViewGroup)
  5. The name of the label should not be wrong, the compiler will not prompt, but also remember the first time the Slidingdrawer written slidingdawer is not prompted, run to the device will directly stop running. Slidingdrawer is a cool drawer that can be used for sliding menus and unfamiliar words to do in graphical layout.
  6. The object of the view class is used to display UI elements, and the ViewGroup class (which is a subclass of the view) is used to display nested objects, can contain other ViewGroup objects and view objects, and the View object does not.
  7. Add <activity></activity> tags to the android manifest to increase activity operations, Whenever you add a page layout XML and Control file Java, remember to add activity to the manifest (register),

    < intent-filter >

    < action android:name = "Android.intent.action.MAIN" />

< category Android:name = "Android.intent.category.LAUNCHER" />

</ Intent-filter > used to set the primary Activity .

  1. Android:layout_height,android:layout_width is the layout size that affects the actual size of the UI element, and if it is the same as match_parent and Fill_parent, fills the parent container; Wrap_content, Wrap the contents so that the setting is the same size and setting.
  2. R.java can be understood as a resource dictionary, does not modify!
  3. The way to assign IDs in XML is android:id= "@+id/name"

    By invoking the Findviewbyid (R.id.name) method in the activity to get the XML-defined component in the Java control file, Java uses the @id/identifier.

  4. EditText's GetText () method obtains a variable of type charsequence, converts it to a string type in order to make a pair of strings, and uses the Equals () method, otherwise it is simply a reference type. The SetText () method parameter is a variable of type charsequence (in fact, this variable is the parent of a string variable, it is temporarily treated as a string type), and when the type of the argument is not of type string, the + "" method is used to turn it into a string type.
  5. Onclicklistener can be used to handle multiple button events, using view to obtain and then switch or if-else if judgment.
  6. The screen layout and layout manager are actually ViewGroup objects that are the objects of those large sub-classes.
  7. Activity Master Stack, 4 big states, 7 ways to see the official Document Map, very clear! Activity can only be managed by the system, the user must not be new,activity with independence, the activity between different apps may call each other, activity stack top element is the element that the user currently sees, task is a task, can contain multiple actions.
  8. The activity is initialized in the OnCreate () method, such as setting the binding UI component, setting the listener, and so on, when one activity switches to another activity, the activity first pause, The onstopped () method is not executed until it is completely covered (another activity executes OnCreate (), OnStart (), Onresume ()). When an activity is about to be destroyed, wait until another activity finishes executing oncreate (), OnStart (), Onresume () before it can be destroyed; there are only two ways to start a new activity, startactivity (Intent objects) and Startactivityforresult (... )。
  9. The intent component is responsible for communication between components, there are many constructors, you can directly set properties such as Component,action, or you can pass data directly.
  10. About passing data, using the bundle object, you can use the Putxxx method to put the data in a key-value pair and use the Intent.putextras (bundle object) to carry the bundle object. Use the activity's Getintent () method on the target page to get the intent, use the intent Getextra () method to get the bundle, and use the bundle's GetXXX () method to get the corresponding variable.
  11. Import imported classes will only import all members and methods of the class, and subclasses and interfaces will not be imported. When we call a method of another class in a class, if it is not a static method, it needs to be instantiated and then called.
  12. When using action for delivery, it is essential to declare the string condition of the action in an activity or other component (and name the string), and then in the other blocks of code (as we've just got the name, you don't actually have a name, Take a name to understand a bit better) call, or use the intent constructor, and then use the intent object's Setaction method to construct, the parameter is the name, you can directly use the string (that is, you can not take the name). Custom action is defined as the private final string member of the activity class, and the variable name follows the package name. Action. String. When you have the same action, you will be prompted to make a selection by jumping out of the dialog box.
  13. Category is a more detailed description of the action, additional category jump activity must keep a <category android:name=" Android.intent.category.DEFAULT " ></category> 's default category.
  14. Data shows you what you want to manipulate, type that indicates the type of data, and that only one can be specified, and the type of type,data is automatically parsed according to data, which is the URI type, using the static method of the URI, parse (String uristring) parsing, generally by the protocol host, and so on, is the file operation path.
  15. The menu includes Optionsmenu,contextmenu,popupmenu, the use of the menu requires a callback method in the activity, and for optionsmenu use of Oncreateoptionsmenu (Menu menu), Internally using a Menuinflate object's inflate () method to populate the menu object with the XML file under the Menu folder, implementing the logic inside the menu requires the use of onoptionsitemmenuselected (MenuItem MenuItem) method, which can be done internally with a simple switch structure. Using the Addsubmenu () method inside the Create method to add a submenu, this method returns a submenu object, creating a submenu object to receive it.

    To be Continued ...

Bubble Android Notes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.