Data storage and interface presentation based on Android application development (i)

Source: Internet
Author: User
Tags mysql index

Directory structure for Android projects
    • Activity: The interface that is displayed when the app is opened
    • SRC: Project Code
    • R.java: Resource ID for all resource files in the project
    • Android.jar:Android jar Package, import this package to use the Android API
    • Libs: Importing third-party jar packages
    • Assets: Storing resource files, for example MP3, video files
    • Bin: Store compiled and packaged files
    • Res: The resource file is stored and all resource files stored in this folder will generate the resource ID
    • Drawable: Storing picture resources
    • Layout: Store the layouts file, assign the layout file to the activity through the resource ID, and the interface will show the layout of the layout file definition.
    • Menu: Define the style of the menu
    • Strings.xml: Storing string resources, each resource will have a resource ID
Android configuration file (manifest file)
    • Specify the package name of the app

      package="com.itheima.helloworld"
      • Data/data/com.itheima.helloworld (the package name specified in the code above)
      • The files generated by the app will be stored in this path
    • All four components of Android need to be configured in the manifest file before use

    • Application configuration is effective for the entire application
    • The activity's configuration takes effect on the activity
DDMS
    • Dalvik Debug Monitor Service
    • Dalvik Commissioning Monitoring Service
Commonly used ADB commands Android Debug Bridge: Android Debug Bridges
    • ADB start-server: Start adb process
    • ADB kill-server: Kill ADB process
    • ADB devices: View the devices currently connected to the development environment and this command can also start the ADB process
    • ADB install xxx.apk: Installing APK to Simulator
    • ADB Uninstall Package Name: Remove an app from the emulator
    • ADB shell: Enter the Linux command line
    • PS: View the running process
    • LS: View the file structure under the current directory
    • Netstat-ano: Viewing the process that occupies the port
Phone Dialer

Function: The user enters a number, clicks the Dial button, starts the system to call the application to call out the number

1. Defining layouts
    1. The component must be set to a wide height, or it cannot be compiled

      android:layout_width="wrap_content"android:layout_height="wrap_content"
    2. If you want to manipulate a component in Java code, the component needs to set the ID so that it can be obtained by ID in the code

      android:id="@+id/et_phone"
2. Set the tap to listen to the button
    1. Set Listen for button

       //通过id拿到按钮对象Button bt_call = (Button) findViewById(R.id.bt_call);//给按钮设置点击bt_call.setOnClickListener(new MyListener());
3. Get the number entered by the user
    //得到用户输入的号码,先拿到输入框组件        EditText et_phone = (EditText) findViewById(R.id.et_phone);        String phone = et_phone.getText().toString();
4. Call out the numbers.
    1. Android system based on the action mechanism to invoke the application of the system, you tell the system what you want to do, the system will be able to do this action of the application to you, if there is no such application, will throw an exception
    2. Set up actions to tell the system through intent

      //把号码打出去    //先创建一个意图对象    Intent intent = new Intent();    //设置动作,打电话    intent.setAction(Intent.ACTION_CALL);    intent.setData(Uri.parse("tel:" + phone));    //把意图告诉系统    startActivity(intent);
    3. Add permissions

      <uses-permission android:name="android.permission.CALL_PHONE"/>
Click on four ways to type the event first
    • Defining a MyListener implementation Onclicklistener interface

      Button bt1 = (Button) findViewById(R.id.bt1);bt1.setOnClickListener(new MyListener());
The second Kind
    • Defines an anonymous inner class implementation Onclicklistener interface

      Button bt2 = (Button) findViewById(R.id.bt2);bt2.setOnClickListener(new OnClickListener() {    @Override    public void onClick(View v) {        System.out.println("介素第二种");    }});
Third Kind
    • Let the current activity implement the Onclicklistener interface

      Button bt3 = (Button) findViewById(R.id.bt3);bt3.setOnClickListener(this);
Fourth type
    • Set the OnClick property to the button node,

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

      public void click(View v){    System.out.println("介素第四种");}
SMS Transmitter

Function: User input number and text message content, click the Send button, call SMS API to send SMS to the specified number

1. Defining layouts
    • Tips for entering boxes

      android:hint="请输入号码"  
2. Complete the Click event
    • Set the OnClick property 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 to send SMS
    //调用发送短信的api    SmsManager sm = SmsManager.getDefault();    //发送短信    sm.sendTextMessage(phone, null, content, null, null);
    • Add permissions

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

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

Other great article articles

jquery Tutorials (9)-dom tree Operations copy elements Android learning note (Android Alertdialog) create List dialog [2]android sharesdk SSO login Sina and MySQL Index type in detail-b-tree index broadcastreceiver use the Alertdialog after the app crashes

More about Android development articles


Data storage and interface presentation based on Android application development (i)

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.