(3) Android Studio uses the basics

Source: Internet
Author: User

I. Directory structure

1. Androidmanifest.xml

It is a manifest file that provides basic information about the application

<?XML version= "1.0" encoding= "Utf-8"?><!--package is the pack name of the Android app, the equivalent of the project ID -<Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.administrator.myapplication2"    >    <!--Basic configuration of the application -    <!--android:allowbackup Allow application backup and recovery -    <!--Android:icon is the app icon after installing the software -    <!--Android:label is the name of TitleBar -    <!--Android:supportsrtl Support Right-to-do layouts, Android 4.2 features later -    <!--android:theme Theme Effects -    <ApplicationAndroid:allowbackup= "true"Android:icon= "@mipmap/ic_launcher"Android:label= "@string/app_name"Android:supportsrtl= "true"Android:theme= "@style/apptheme">        <!--an activity -        <ActivityAndroid:name=". Mainactivity ">            <!--Intent Filter -            <Intent-filter>                <!--which activity is displayed first when we launch the app -                <ActionAndroid:name= "Android.intent.action.MAIN" />                <!--indicates that activity should be included in the system's Initiator (launcher) (allows the user to start it) -                <categoryAndroid:name= "Android.intent.category.LAUNCHER" />            </Intent-filter>        </Activity>    </Application></Manifest>

2.MainActivity

All the. java files are stored in the Java folder ,

 Public class extends appcompatactivity {   ///OnCreate The method that must be executed after the activity is created     @Override      protectedvoid  onCreate (Bundle savedinstancestate) {        super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main);    }}

3.activity.xml

The layout file is stored in the folder under Layout

4.drawable

The icons used in the program are usually placed under this folder.

5.mipmap

Used to store the app launch icon, which can be optimized to different resolutions

6.values

Used to store templates such as colors, themes, strings, etc.

7. Testing

Used to write test cases

8. Building a project with Gradle

Settings.gradle used to specify the module that the project introduces

Build.gradle (Project): code-managed Warehouse

Build.gradle (Module):

Second, shortcut keys

Note: ctrl+/

Hint: ctrl+alt+ space

Jump into method or class: Ctrl + LEFT mouse button

Format code: CTRL+ALT+L

Run the app again (the emulator opens) Ctrl+f5

Third, log cat

Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle;ImportAndroid.util.Log;// Public classMainactivityextendsappcompatactivity {//OnCreate methods that must be executed after an activity is created@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); //The first parameter generally passes in the current class name and is used primarily for information filtering. The second parameter prints the exact contents of theLOG.V ("Mainactivity", "Print trivial log information, lowest level--"); LOG.D ("Mainactivity", "Debug print debugging information higher than V"); LOG.I ("Mainactivity", "info print more important data, higher than D"); LOG.W ("Mainactivity", "Warn print warning message indicating that there may be a higher risk than I"); LOG.E ("Mainactivity", "Error print fault message, highest level"); }}

Select the package that appears

Iv. adb directives

Five, Toast tips

VI. Click events

Seven, pack apk

Https://jingyan.baidu.com/article/c843ea0bbfae3777931e4ac3.html

Eight, import jar package

Switch to Project,

Locate the Libs folder, copy the jar package

Right-click on the JAR package

After the success will be more

(3) Android Studio uses the basics

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.