Data storage and interface display based on Android Application Development (I): android Application Development

Source: Internet
Author: User

Data storage and interface display based on Android Application Development (I): android Application Development
Directory structure of the Android Project

  • Activity: interface displayed when an application is opened
  • Src: project code
  • R. java: Resource id of all resource files in the project
  • Android. jar: Android jar package. Only Android APIs can be used to import this package.
  • Libs: Import third-party jar packages
  • Assets: stores resource files, such as mp3 and video files.
  • Bin: stores compiled and packaged files.
  • Res: stores resource files. Resource IDs are generated for all resource files stored in this folder.
  • Drawable: Stores image resources.
  • Layout: stores the layout file and assigns the layout file to the activity through the resource id. The layout defined by the layout file is displayed on the page.
  • Menu: defines the menu style
  • Strings. xml: stores string resources. Each resource has a resource id.
Configuration file for Android (configuration file)
  • Application Package name

    package="com.itheima.helloworld"
    • Data/com. itheima. helloworld (package name specified in the Code above)
    • All files generated by the application are stored in this path.
  • The four components of Android must be configured in the configuration file before use.

  • The application configuration takes effect for the entire application.
  • The activity configuration takes effect for the activity.
DDMS
  • Dalvik debug monitor service
  • Dalvik debugging Monitoring Service
Common adb commands: Android debug bridge
  • Adb start-server: start the adb Process
  • Adb kill-server: kills the adb Process
  • Adb devices: view the current device connected to the development environment. This command can also start the adb Process
  • Adb install XXX.apk: install apk to the simulator
  • Adb uninstall package name: Delete the application in the simulator
  • Adb shell: Enter the linux Command Line
  • Ps: view running processes
  • Ls: view the file structure in the current directory
  • Netstat-ano: view the process that occupies the port
Dialing device

Function: enter a number and click the call button to start the application that calls the system to call the number.

1. Define layout 2. Set the button to listen 3. Get the number entered by the user
// Obtain the number entered by the user. First, obtain the EditText et_phone = (EditText) findViewById (R. id. et_phone); String phone = et_phone.getText (). toString ();
4. Call out the number The first method of writing click events
  • Define a MyListener to implement the onClickListener Interface

    Button bt1 = (Button) findViewById(R.id.bt1);bt1.setOnClickListener(new MyListener());
Second
  • Define an anonymous internal class to implement the onClickListener Interface

    Button bt2 = (Button) findViewById (R. id. bt2); bt2.setOnClickListener (new OnClickListener () {@ Override public void onClick (View v) {System. out. println ("second ");}});
Third
  • Enable the current activity to implement the onClickListener Interface

    Button bt3 = (Button) findViewById(R.id.bt3);bt3.setOnClickListener(this);
Fourth
  • Set the onClick attribute for the Button node,

     android:onClick="click"
  • Then define the method with the same name as the property value in the activity.

    Public void click (View v) {System. out. println ("comment fourth ");}
SMS sender

Function: Enter the number and text message content, click the send button, and call the SMS api to send the text message to the specified number.

1. Define the Layout
  • Prompt in the input box

    Android: hint = "Enter the number"
2. Click Complete
  • Set the onClick attribute for the Button component first.
  • onClick="send"
  • Define this method in Activity
  • public void send(View v){}
3. Get the number and content entered by the user
    EditText et_phone = (EditText) findViewById(R.id.et_phone);    EditText et_content = (EditText) findViewById(R.id.et_content);    String phone = et_phone.getText().toString();    String content = et_content.getText().toString();
4. Call the api for sending text messages
// Call the SMS sending api SmsManager sm = SmsManager. getDefault (); // send SMS sm. sendTextMessage (phone, null, content, null, null );
  • Add permission

     <uses-permission android:name="android.permission.SEND_SMS"/>
  • If the text message is too long, you need to split it.

    List<String> smss = sm.divideMessage(content);

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.