Learning Record: No.1

[Andrews]
1. Install APK remember considered compatible with 7.0, Uri can not build directly from Uri.parse (), to use FileProvider build Uri.

<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="${applicationId}.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_path" />
</provider>

 

< Paths : Android xmlns = "http://schemas.android.com/apk/res/android" > 
    <! - / Storage / emulated / 0 / the Download / files can be accessed at -> 
    < External-path
         name = "beta_external_path" 
        path = "the Download /"  /> 

    <-! / Storage / emulated / 0 / the Android / Data / file can access -> 
    < External path-
         name = "beta_external_files_path" 
        path = "the Android / Data / "  /> 
</ Paths >

 

public  static  void installAPK (the Context context, String apkPath) { 
    the Intent Intent = new new the Intent (); 
    intent.setAction (Intent.ACTION_VIEW); 
    intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); 
    // 7.0 or more documents to be provided so that the external application program 
    uri uri = FileProvider.getUriForFile (. context, context.getApplicationContext () getPackageName () + ".fileprovider", new new file (apkPath));
     // 7.0 above can not access the file as something like the (comments)
     // the Intent. setDataAndType (Uri.parse ( "File: // " + apkPath), "file application / vnd.android.package-Archive"); 
    intent.setDataAndType (URI, "file application / vnd.android.package-Archive");
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    context.startActivity(intent);
}

 

2. FLAG_ACTIVITY_NEW_TASK taskAffinity used in conjunction with the (rules to keep in mind: directly to the foreground task stack display, the task stack state unchanged)

Task Stack 1: 
ActivityA > ActivityB 

task stack 2: 
ActivityC > ActivityD

 1 . If ActivityB started ActivityC, the task stack 2 directly back to the front display, the display is ActivityD.
2. If ActivityB started ActivityE (ActivityE of taskAffinity belong to the task stack 2), the task stack 2 back to the front desk, ActivityE created and displayed.

 


[Distal]
1. Use the table-cell, the inner table-cell common floating elements and inline-block element vertically centered features (not the overall center of each element centrally, the code reference to the following display in a browser).

<!DOCTYPE html>
<html>
    <head>
        <style type="text/css">
        .root {
            background-color: gray;
            height: 80px;
            width: 200px;
            display: table-cell;
            vertical-align: middle;
            font-size: 0px;
        }

        .left {
            float: left;
            height: 30px;
            width: 50px;
            background-color: red;
            position: relative;
            font-size: medium;
        }

        .left-text {
            width: 20px;
            height: 20px;
            background-color: pink;
            position: absolute;
            transform: translate(-50%, -50%);
            top: 50%;
            left: 50%;
            line-height: 20px;
            text-align: center;
        }

        .right {
            display: inline-block;
            height: 40px;
            width: 40px;
            line-height: 40px;
            text-align: center;
            background-color: green;
            font-size: medium;
        }

        </style>
    </head>

    <body>
        <div id="root" class="root">
            <div id="left" class="left">
                <div class="left-text">
                    a
                </div>
            </div>
            <div class="right">
                b
            </div>
        </div>
    </body>
</html>

 

 

2. Vue example, using the ref: A component is a Vue example, an application consists of a root Vue composition, when constructing each instance Vue receives a configuration parameter, the template ref Vue DOM can reference element or component instance Vue .

< Template > 
    < div > 
        <-!   . VUE through this $ refs.left access to the DOM element -> 
        < div ref = "left" > 
           
        </ div > 

        <-!   VUE through this $ refs.right. access Vue example, it can call the method -> 
        < VUE-Button REF = "right" > 

        </ VUE-Button > 

    </ div > 
</ Template >

 


3. v-on: Use should pay attention to three different points, v-on: click inside the $ event parameter is a DOM element, v-on: eventName custom event $ event parameter is the data transfer from the sub-assembly trigger event remember v-on is not this (being not to understand why).

< Template > 
    < div class = "root" > 
        <-! : Div click method when called directly Vue instance 1 -> 
        < div v-ON: the Click = "the Clear" > </ div > 

        <-! - 2: 1 with the same effect -> 
        < div V-ON: the Click = "Clear ($ Event)" > </ div > 

        <-! . 3: $ Event parameter transfer subassembly -> 
        < vue- SELECT V-ON: changeData = "Change ($ Event)" > </ VUE-SELECT > 

        <-! . 4: 3 with the same effect -> 
        <vue-select v-on:changeData="change"></vue-select>
    </div>
</template>


methods: {
    clear(e){
        alert(e.target.innerText)
    },
    change(v){
         alert(v)
    }
}

 

4. JQuery is an antique, and few opportunities later used:

(1) look at the $ () returns a JQuery object is, in fact, he is a class array (because of the length property), by eq (index) will create a new jQuery object represents an element of the position of the operation, if not through eq () method to specify the operating element is that all elements operate.

(2) See the official description of some EQ () is: Given a jQuery object that represents a set of DOM elements, the .eq () method constructs a new jQuery object from one element within that set.

Guess you like

Origin www.cnblogs.com/nicojerry/p/12174172.html
Recommended