零碎知識點總結

  1.nevigation drawer總結,佈局文件
最外面是一個android.support.v4.widget.DrawerLayout,裏面兩個標籤,第一個必須是內容(至關於slidingdrawer的content),第二個是handle(至關於slidingdrawer的handler)順序不可變。
2.hanler通常爲listview或者其餘能夠選擇其中一項的控件。drawLayout能夠爲其設置打開關閉的監聽事件,能夠使用android提供的actionbardrawertoggle,或者本身設置監聽器,本身實現。
3.實現invalidateoptionsmenu方法後系統會去調用onprepareoptionsmenu方法。其方法內能夠對經過oncreateoptionsmenu實現好的menu進行對menu的一些更改,好比能夠設置其的可見與不可見狀態。
Intent intent=new Intent(Intent.ACTION_QUERY);
intent.putExtra(SearchMnager.SEARCH,Charsequence value);
SearchManger的QUERY的官方解釋

public static final String QUERY

Added in  API level 1

Intent extra data key: Use this key with content.Intent.getStringExtra() to obtain the query string from Intent.ACTION_SEARCH. html

Constant Value: "query"

public Intent putExtra (String name, CharSequence value)

Added in  API level 1

Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll". java

Parameters
name The name of the extra data, with package prefix.
value The CharSequence data value.
Returns
  • Returns the same Intent object, for chaining multiple calls into a single statement.
See Also
  • putExtras(Intent)
  • removeExtra(String)
  • getCharSequenceExtra(String)

  • if   (intent.resolveActivity(getPackageManager())!=   null ) {
                         startActivity(intent);

                    }就是尋找符合條件的component

    public ComponentName resolveActivity (PackageManager pm)

    Added in  API level 1

    Return the Activity component that should be used to handle this intent. The appropriate component is determined based on the information in the intent, evaluated as follows: android

    If getComponent() returns an explicit class, that is returned without any further consideration. app

    The activity must handle the CATEGORY_DEFAULT Intent category to be considered. ide

    If getAction() is non-NULL, the activity must handle this action. 佈局

    If resolveType(ContentResolver) returns non-NULL, the activity must handle this type. ui

    If addCategory(String) has added any categories, the activity must handle ALL of the categories specified. this

    If getPackage() is non-NULL, only activity components in that application package will be considered. lua

    If there are no activities that satisfy all of these conditions, a null string is returned. spa

    If multiple activities are found to satisfy the intent, the one with the highest priority will be used. If there are multiple activities with the same priority, the system will either pick the best activity based on user preference, or resolve to a system class that will allow the user to pick an activity and forward from there.

    This method is implemented simply by calling resolveActivity(Intent, int) with the "defaultOnly" parameter true.

    This API is called for you as part of starting an activity from an intent. You do not normally need to call it yourself.

    Parameters
    pm The package manager with which to resolve the Intent.
    Returns
    • Name of the component implementing an activity that can display the intent.
    See Also
    • setComponent(ComponentName)
    • getComponent()
    • resolveActivityInfo(PackageManager, int)
    • int imageId=imageview.getIdentifier(String name,String defType,String defPack);該方法是經過image的名字,包名,類型,爲drawable樓來獲得image的資源定位符,暫且這麼說吧。但前提是imag的名字與其在drawable文件夾中圖片的名字是相同的。
    • public int getIdentifier (String name, String defType, String defPackage)

      Added in  API level 1

      Return a resource identifier for the given resource name. A fully qualified resource name is of the form "package:type/entry". The first two components (package and type) are optional if defType and defPackage, respectively, are specified here.

      Note: use of this function is discouraged. It is much more efficient to retrieve resources by identifier than by name.

      Parameters
      name The name of the desired resource.
      defType Optional default resource type to find, if "type/" is not included in the name. Can be null to require an explicit type.
      defPackage Optional default package to find, if "package:" is not included in the name. Can be null to require an explicit package.
      Returns
      • int The associated resource identifier. Returns 0 if no such resource was found. (0 is not a valid resource ID.)
相關文章
相關標籤/搜索