• android之‘com.example.android.apis.view’的代码段


    1.AutoCompleteTextView

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_dropdown_item_1line, COUNTRIES);
    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
    textView.setAdapter(adapter);
    //this word for auto-completion by words
    textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
    static final String[] COUNTRIES = new String[] {
        "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
        "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
        "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
        "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
        "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
        "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory",
        "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
        "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde",
        "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
        "Christmas Island", "Cocos (Keeling) Islands"}

    2.LinearLayout 的android:baselineAlignedChildIndex="2"属性作用。一张图片说明其作用

    3.GridLayout 简化了对复杂布局的处理,包括性能提高不是一倍两倍。但是不支持SDK版本低于14的手机。不过有兼容包,不过我还没找到。

    请看布局代码:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
         Copyright (C) 2011 The Android Open Source Project
    
         Licensed under the Apache License, Version 2.0 (the "License");
         you may not use this file except in compliance with the License.
         You may obtain a copy of the License at
    
              http://www.apache.org/licenses/LICENSE-2.0
    
         Unless required by applicable law or agreed to in writing, software
         distributed under the License is distributed on an "AS IS" BASIS,
         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         See the License for the specific language governing permissions and
         limitations under the License.
    -->
    
    <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:alignmentMode="alignBounds"
        android:columnCount="4"
        android:columnOrderPreserved="false"
        android:useDefaultMargins="false" >
    
        <EditText
            android:layout_columnSpan="3"
            android:layout_gravity="fill" />
    
        <Button android:text="/"/>
    
        <Button android:text="1" />
    
        <Button android:text="2" />
    
        <Button android:text="3" />
    
        <Button android:text="*" />
    
        <Button android:text="4" />
    
        <Button android:text="5" />
    
        <Button android:text="6" />
    
        <Button android:text="-" />
    
        <Button android:text="7" />
    
        <Button android:text="8" />
    
        <Button android:text="9" />
    
        <Button
            android:layout_gravity="fill_vertical"
            android:layout_rowSpan="3"
            android:text="+" />
    
        <Button
            android:layout_columnSpan="2"
            android:layout_gravity="fill"
            android:text="0" />
    
        <Button android:text="00" />
    
        <Button
            android:layout_columnSpan="3"
            android:layout_gravity="fill_horizontal"
            android:text="=" />
    
    </GridLayout>

    效果图如下:

  • 相关阅读:
    Feign性能优化注意事项--超时
    Android MVP+Retrofit+dagger2+RxAndroid框架整合
    Android adb命令,linux中各种命令
    【视频音频】雷霄骅开源视音频项目汇总
    Android LitePal介绍与使用说明
    AndroidStudio第一次提交项目代码到git服务器/github
    Android框架之路——Fragmentation的使用(流式交互Demo)
    Android Studio 升级到3.0后出现编译错误.gradlecaches ransforms-1files-1.1*****-release.aar
    Android Studio你必须学会的快捷键(Eclipse转AS必看)
    Intellij IDEA常用配置详解
  • 原文地址:https://www.cnblogs.com/fanglove/p/3461295.html
Copyright © 2020-2023  润新知