Difference between revisions of "Android Studio: Sample"

From OnnoWiki
Jump to navigation Jump to search
(New page: Samples Welcome to code samples for Android developers. Here you can browse sample code and learn how to build different components for your applications. Use the categories on the left t...)
 
Line 4: Line 4:
  
 
Each sample is a fully functioning Android app. You can browse the resources, source files and see the overall project structure. You can copy and paste the code you need, and if you want to share a link to a specific line you can double-click it to the get the URL.
 
Each sample is a fully functioning Android app. You can browse the resources, source files and see the overall project structure. You can copy and paste the code you need, and if you want to share a link to a specific line you can double-click it to the get the URL.
Import Samples from GitHub
+
 
 +
==Import Samples from GitHub==
  
 
Android Studio provides easy access to import Android code samples from GitHub and is the recommended method to retrieve Android code samples.
 
Android Studio provides easy access to import Android code samples from GitHub and is the recommended method to retrieve Android code samples.
Line 10: Line 11:
 
To import a code sample into Android Studio:
 
To import a code sample into Android Studio:
  
    In the Android Studio menu, select File > Import Sample to open the Import Sample wizard.
+
* In the Android Studio menu, select File > Import Sample to open the Import Sample wizard.
    Select a sample to import and click Next.
+
* Select a sample to import and click Next.
    Specify the application name and project location if different from the displayed settings.
+
* Specify the application name and project location if different from the displayed settings.
    Click Finish.
+
* Click Finish.
  
    The sample project opens in a new Android Studio project.
+
The sample project opens in a new Android Studio project.
  
 
Note: When starting Android Studio, you can also select Import an Android code sample in the Welcome to Android Studio wizard to import a sample project from GitHub as a new project.
 
Note: When starting Android Studio, you can also select Import an Android code sample in the Welcome to Android Studio wizard to import a sample project from GitHub as a new project.
  
 
For more information about importing samples, see Easy access to Android code samples on GitHub.
 
For more information about importing samples, see Easy access to Android code samples on GitHub.
Download Samples
+
 
 +
==Download Samples==
  
 
Although importing samples from Android Studio is the recommended method, you can also use the categories on the left to browse the available samples and learn how to build different components for your applications.
 
Although importing samples from Android Studio is the recommended method, you can also use the categories on the left to browse the available samples and learn how to build different components for your applications.
Line 28: Line 30:
 
To import a downloaded project:
 
To import a downloaded project:
  
    Unpack the downloaded project package.
+
* Unpack the downloaded project package.
    In Android Studio, chose File > Import Project and select the root folder of the unpacked project.
+
* In Android Studio, chose File > Import Project and select the root folder of the unpacked project.
  
    Android Studio may ask you to choose the type of project you are importing. If this is the case, make sure to choose Import project from external model and select the Gradle option.
+
Android Studio may ask you to choose the type of project you are importing. If this is the case, make sure to choose Import project from external model and select the Gradle option.
  
 
Note: When starting Android Studio, you can also select Import Non-Android Studio project in the Welcome to Android Studio wizard to import a downloaded sample project.
 
Note: When starting Android Studio, you can also select Import Non-Android Studio project in the Welcome to Android Studio wizard to import a downloaded sample project.

Revision as of 08:58, 24 February 2015

Samples

Welcome to code samples for Android developers. Here you can browse sample code and learn how to build different components for your applications. Use the categories on the left to browse the available samples.

Each sample is a fully functioning Android app. You can browse the resources, source files and see the overall project structure. You can copy and paste the code you need, and if you want to share a link to a specific line you can double-click it to the get the URL.

Import Samples from GitHub

Android Studio provides easy access to import Android code samples from GitHub and is the recommended method to retrieve Android code samples.

To import a code sample into Android Studio:

  • In the Android Studio menu, select File > Import Sample to open the Import Sample wizard.
  • Select a sample to import and click Next.
  • Specify the application name and project location if different from the displayed settings.
  • Click Finish.

The sample project opens in a new Android Studio project.

Note: When starting Android Studio, you can also select Import an Android code sample in the Welcome to Android Studio wizard to import a sample project from GitHub as a new project.

For more information about importing samples, see Easy access to Android code samples on GitHub.

Download Samples

Although importing samples from Android Studio is the recommended method, you can also use the categories on the left to browse the available samples and learn how to build different components for your applications.

If you want to download a complete project, just click on any source file in the project and click the Download link in the upper right of the source page.

To import a downloaded project:

  • Unpack the downloaded project package.
  • In Android Studio, chose File > Import Project and select the root folder of the unpacked project.

Android Studio may ask you to choose the type of project you are importing. If this is the case, make sure to choose Import project from external model and select the Gradle option.

Note: When starting Android Studio, you can also select Import Non-Android Studio project in the Welcome to Android Studio wizard to import a downloaded sample project.

Note: At this time, the downloadable projects are designed for use with Gradle and Android Studio.



Referensi