About NotePad Tutorial

    今天學習NotePad Tutorial。把本身認爲重要的Copy過來。android

   一,Here are some things you should know about a layout file:ide

      1,All Android layout files must start with the XML header line: <?xml version="1.0" encoding="utf-8"?>.學習

      2,The next definition will often (but not always) be a layout definition of some kind, in this case a LinearLayout.this

      3,The XML namespace of Android should always be defined in the top level component or layout in the XML so thatandroid: tags can be used through the rest of the file:spa

  • xmlns:android="http://schemas.android.com/apk/res/android"rest

 二,關於startActivity()和startActivityForResult():code

      The startActivityForResult() method fires the Intent in a way that causes a method in our Activity to be called when the new Activity is completed. The method in our Activity that receives the callback is calledonActivityResult() and we will implement it in a later step. The other way to call an Activity is usingstartActivity() but this is a "fire-and-forget" way of calling it — in this manner, our Activity is not informed when the Activity is completed, and there is no way to return result information from the called Activity withstartActivity().component

  三,關於onActivityResult():orm

   onActivityResult() is the overridden method which will be called when an Activity returns with a result. (Remember, an Activity will only return a result if launched withstartActivityForResult.) The parameters provided to the callback are:xml

      1,requestCode — the original request code specified in the Intent invocation                       (either ACTIVITY_CREATE or ACTIVITY_EDIT for us).

      2,resultCode — the result (or error code) of the call, this should be zero if everything was OK, but may have a non-zero code indicating that something failed. There are standard result codes available, and you can also create your own constants to indicate specific problems.

      3,intent — this is an Intent created by the Activity returning results. It can be used to return data in the Intent "extras."

相關文章
相關標籤/搜索