activity_activitywenben.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
> <AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/atv_1"
android:hint="自动完成文本编辑框"/> <Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sper_1">
</Spinner> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示状态栏提示"
android:onClick="notification_onclick"/>
</LinearLayout>

java

package com.example.chenshuai.test321;

import android.app.Notification;
import android.app.NotificationManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Spinner;
import android.widget.Toast; public class Activitywenben extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activitywenben); //自动提示文本框
AutoCompleteTextView autv_1 = (AutoCompleteTextView)findViewById(R.id.atv_1); //设置数据源 String[] str = {"a","aa","aaa","ab","abc","abcd"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.listview_layout,str); autv_1.setAdapter(adapter); //下拉列表
Spinner sper_1 = (Spinner)findViewById(R.id.sper_1); sper_1.setAdapter(adapter); sper_1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(Activitywenben.this, "position" +position, Toast.LENGTH_SHORT).show();
} @Override
public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(Activitywenben.this, "什么也不选", Toast.LENGTH_SHORT).show(); }
});
} public void notification_onclick(View view){ //1.获取状态栏消息管理器
NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); //
Notification nt = new Notification.Builder(this) .setContentTitle("这是一条消息通知")
.setContentText("hello world 通知:明天休息")
.setTicker("显示在状态栏中的信息")
.setSmallIcon(R.drawable.anniu1)
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_SOUND)
.build(); //交给管理器发出消息
manager.notify(0,nt);
}
}

Android——适配器其他组件(AutoCompleteTextView:自动完成文本编辑框;Spinner:下拉列表)的更多相关文章

  1. Android开发10.2:UI组件AutoCompleteTextView(自动完成文本框)

    概述 AutoCompleteTextVeiw(自动完成文本框)从 EditText派生而出  PS :EditText用法介绍           当用户输入一定字符后,自动完成自动完成文本框会显示 ...

  2. AutoCompleteTextView自动完成文本框

    AutoCompleteTextView是从EditText派生出来的,比普通编辑框多了一个功能,当用户输入一定字符后,自动完成文本框会显示一个下拉单,供用户选择,当选中一个后,被选中的内容会显示在文 ...

  3. Android:控件AutoCompleteTextView 自动提示

    在文本框中输入,要这样的提示效果,如果你输入的是aac,在输入aa后,选择aac,文本框的内容会自动补齐,输入aac(类似百度搜索文本框的显示结果)   <AutoCompleteTextVie ...

  4. 011 Android AutoCompleteTextView(自动完成文本框)的基本使用

    1.XML布局 android:completionThreshold="1":这里我们设置了输入一个字就显示提示 (1)主界面布局 <?xml version=" ...

  5. Android基础TOP5_1:AutoCompleteTextView自动补全文本框

    1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...

  6. Android零基础入门第47节:自动完成文本框AutoCompleteTextView

    原文:Android零基础入门第47节:自动完成文本框AutoCompleteTextView 上一期学习的Spinner的使用,掌握的怎么样?本期一起来学习AutoCompleteTextView的 ...

  7. Android 自学之自动完成文本框 AutoCompleteTextView

    自动完成文本框(AutoCompleteTextView)从EditText派生而出,实际上他也是一个编辑框,但他比普通的编辑框多了一个功能:当用户输入一定字符后,自动完成文本框会显示一个下拉菜单,供 ...

  8. Android——控件AutoCompleteTextView 自动提示

    Android:控件AutoCompleteTextView 自动提示 在输入框中输入我们想要输入的信息就会出现其他与其相关的提示信息,这种效果在Android中是用AutoCompleteTextV ...

  9. android适配器Adapter

    一.什么是适配器,适配器有什么用? 适配器是AdapterView视图(如ListView - 列表视图控件.Gallery - 缩略图浏览器控件.GridView - 网格控件.Spinner - ...

随机推荐

  1. jsp中Undefined type: xxxx...

    在测试jsp的动作元素<jsp:useBean >时,写了一个计数器的栗子: JavaBean: package com.pers.count; /** * @author liangya ...

  2. 【LeetCode】24. Swap Nodes in Pairs (3 solutions)

    Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For exam ...

  3. 【java设计模式】之 代理(Proxy)模式

    代理模式的核心作用就是通过代理,控制对对象的访问.这跟实际中是一样的,比如说明星都有经纪人,这就是一个代理,比如有人要找某明星拍戏,那么首先处理这事的是他的经纪人,虽然拍戏需要自己拍,但是拍戏前后的一 ...

  4. Java程序作linux服务并且开机自动启动[转]

    以有个java应用名称为test,打包为test.jar,程序入口为cn.com.ppnote.SocketServer. 下面在linux的/opt下建立testapp目录,复制test.jar到/ ...

  5. C 标准库IO缓冲区和内核缓冲区的区别

    1.C标准库的I/O缓冲区          UNIX的传统 是Everything is a file,键盘.显示器.串口.磁盘等设备在/dev 目录下都有一个特殊的设备文件与之对应,这些设备文件也 ...

  6. CListCtrl控件中显示进度条

    CListCtrl控件的subitem中显示进度条 http://www.codeproject.com/Articles/6813/List-Control-Extended-for-Progres ...

  7. appserv - 最简单的绑定路径

    补充:此方法比较low. 推荐伪静态:http://www.cnblogs.com/CyLee/p/5544119.html 找到路径C:\AppServ\Apache24\conf\httpd.co ...

  8. python标准库介绍——11 atexit 模块详解

    === atexit 模块=== (用于2.0版本及以上) ``atexit`` 模块允许你注册一个或多个终止函数(暂且这么叫), 这些函数将在解释器终止前被自动调用. 调用 ``register`` ...

  9. PYNQ = Python + ZYNQ —— ZYNQ部分功能的Python化

    PYNQ优点:1.    Python用于ZYNQ开发,Python库和FPGA硬件库可以直接调用,极大加快开发进程.缩短开发周期.降低开发难度,更方便.快捷:2.    用PYNQ开发,当Pytho ...

  10. PCIE BAR空间

    PCIE应用程序编程,首先就要理清PCIE BAR空间到底说的是什么.在PCIE配置空间里,0x10开始后面有6个32位的BAR寄存器,BAR寄存器中存储的数据是表示PCIE设备在PCIE地址空间中的 ...