zoukankan      html  css  js  c++  java
  • 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>

    效果图如下:

  • 相关阅读:
    js实现分享到QQ
    js 复制粘贴
    js弹窗 js弹出DIV,并使整个页面背景变暗
    PHP实现大转盘抽奖算法
    ext 树节点操作
    ExtJS4图片验证码的实现
    随笔分类
    Oracle、MySql、SQLServer 数据分页查询
    Repeater控件使用(含删除,分页功能)
    SQL compute by 的使用
  • 原文地址:https://www.cnblogs.com/fanglove/p/3461295.html
Copyright © 2011-2022 走看看