Android learning 4-apidemos

Source: Internet
Author: User

I have never known what to write, because the apidemos provided by Android are well-developed by the real experts, and the documents are also very beautiful, I personally think that a lot of things can be used directly, changed on top, and then become our own things. It sounds like "standing on the shoulders of giants ", it is hard to say "Stealing ". I can't do it anymore. Learn first

Open eclipse and click Android SDK and AVD manager.


Select a created AVD.


Start up. Some machines may slow down and give him some time to have a cup of tea.

After entering the interface, the upper left corner is apidemos.


Click


After a rough look, I will not go to the document to find a detailed summary. I read a book called Android Application Development yesterday, which contains some summary, however, this book was not written into the NFC module yet. It happened to be seen by Zhang Yifei, saying that it is used for sensing. The best example is to use a mobile phone to brush tickets at the World Expo, I checked in the encyclopedia:

NFC is short for Near Field Communication, which is short for near-range wireless communication technology. NFC, developed jointly by Philips and Sony, is a non-contact identification and interconnection technology that can be used in mobile devices, consumer electronic products, PCs
And smart control tools for close-range wireless communication. NFC provides a simple, touch-based solution that allows consumers to easily and intuitively exchange information, access content and services. Http://baike.baidu.com/view/917495.htm)

Unfortunately, there is no expected effect. It is estimated that a transmitter should be simulated in eclipse.



App

Examples in this directory demonstrate how to create program-level elements, such as activity, warning, dialog box, intent, and service.


Content

The example in this directory shows how to read useful information from a common file, resource file, and XML file.


The demonstration results may not be easy to see at first glance, but the functions are available.

Graphics

This directory contains many graphics examples, such as bitmap operations, image capturing, layer operations, and OpenGL usage.


Open OpenGL ES




There are very beautiful animations in it. You can make a lot of more beautiful things based on these.

Media

Examples include aduiofx, mediaplayer, and videoview.



NFC

There is no clue about the current location. Some friends have a deep understanding of this. You can share it with me.


OS

Here we demonstrate how to call system services, including Morse code, rotation vector, sensors, and SMS messaging.

The last one I know is the text message sending service.



Text

Examples of text contained here


Views

Here are many examples of view components. Here we can find the usage of these components and how to set various parameters.



This section describes the functions and functions of these apidemos. The specific application depends on the situation.

The source code of these examples is in the sampls file under the android installation directory.


Open


Here are the labels of many versions. I use android2.3, so his version number is 10.


Open


The source code is all here.

We still need to use the documentation. After all, it is a pity that such a good document cannot be read.


It is too detailed. If I go to the class to make an axe, it is really a shame. However, I will share my learning experience.

Finally, if you think that every time you create your own demo, you need to create a project, and an icon is displayed on the screen, you can put your own demo in apidemos.

We will use an example to illustrate how to add a toasttest under views.

The specific method is as follows:

First, open the android installation path \ samples \ Android-10 \ apidemos \ androidmanifest. xml.


I will not post the code because there are too many codes.

Create a project with eclipse


Select android2.3.3

The package name must be written as com. example. Android. APIs, because

Create a toast_test.xml file in the layout folder.


The Code is as follows:

<?xml version="1.0" encoding="utf-8" ?><RelativeLayout android:id="@+id/RelativeLayout01"android:layout_width="wrap_content"android:layout_height="wrap_content"xmlns:android="http://schemas.android.com/apk/res/android"><TextView android:id="@+id/TextView01"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Guess my favorite color:"/><RadioGroup android:id="@+id/RadioGroup01"android:layout_below="@id/TextView01"android:layout_width="wrap_content"android:layout_height="wrap_content"><RadioButton android:id="@+id/redButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="red Button"/><RadioButton android:id="@+id/greenButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="green Button"/><RadioButton android:id="@+id/blueButton"android:layout_width="wrap_content"android:layout_height="wrap_content" android:text="blue Button"/></RadioGroup></RelativeLayout>

Create an activity in the src directory. The package name is com. example. Android. APIs. view, because it will be displayed under views.


The Code is as follows:



Package COM. example. android. APIS. view; import COM. example. android. APIS. r; import android. app. activity; import android. OS. bundle; import android. view. view; import android. widget. radiobutton; import android. widget. toast; public class toasttest extends activity {/** called when the activity is first created. * // @ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); Final radiobutton redbutton = (radiobutton) findviewbyid (R. id. redbutton); // Add a listener redbutton. setonclicklistener (new view. onclicklistener () {public void onclick (view v) {toast. maketext (toasttest. this, "Oooh, red", toast. length_short ). show ();}});

Put the two files in the corresponding directory:

Android installation path \ samples \ Android-10 \ apidemos \ res \ Layout

Android installation path \ samples \ Android-10 \ apidemos \ SRC \ com \ example \ Android \ APIs \ View

Finally, modify the androidmanifest. xml file: Android installation path \ samples \ Android-10 \ apidemos

Add the newly created activity to this file. It should be added after textswitch1.

      <activity android:name=".view.TextSwitcher1"                android:label="Views/TextSwitcher">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.SAMPLE_CODE" />            </intent-filter>        </activity><activity android:name=".view.ToastTest" android:label="Views/ToastTest"><intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.SAMPLE_CODE" />            </intent-filter></activity>        <activity android:name=".view.ImageButton1"                android:label="Views/ImageButton">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.SAMPLE_CODE" />            </intent-filter>        </activity>

Then run it. Unfortunately, I didn't succeed, but the method must be like this. I have been searching for a long time and I have no idea. If any one can find the problem, leave a comment.






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.