Android——适配器其他组件(AutoCompleteTextView:自动完成文本编辑框;Spinner:下拉列表)
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:下拉列表)的更多相关文章
- Android开发10.2:UI组件AutoCompleteTextView(自动完成文本框)
概述 AutoCompleteTextVeiw(自动完成文本框)从 EditText派生而出 PS :EditText用法介绍 当用户输入一定字符后,自动完成自动完成文本框会显示 ...
- AutoCompleteTextView自动完成文本框
AutoCompleteTextView是从EditText派生出来的,比普通编辑框多了一个功能,当用户输入一定字符后,自动完成文本框会显示一个下拉单,供用户选择,当选中一个后,被选中的内容会显示在文 ...
- Android:控件AutoCompleteTextView 自动提示
在文本框中输入,要这样的提示效果,如果你输入的是aac,在输入aa后,选择aac,文本框的内容会自动补齐,输入aac(类似百度搜索文本框的显示结果) <AutoCompleteTextVie ...
- 011 Android AutoCompleteTextView(自动完成文本框)的基本使用
1.XML布局 android:completionThreshold="1":这里我们设置了输入一个字就显示提示 (1)主界面布局 <?xml version=" ...
- Android基础TOP5_1:AutoCompleteTextView自动补全文本框
1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...
- Android零基础入门第47节:自动完成文本框AutoCompleteTextView
原文:Android零基础入门第47节:自动完成文本框AutoCompleteTextView 上一期学习的Spinner的使用,掌握的怎么样?本期一起来学习AutoCompleteTextView的 ...
- Android 自学之自动完成文本框 AutoCompleteTextView
自动完成文本框(AutoCompleteTextView)从EditText派生而出,实际上他也是一个编辑框,但他比普通的编辑框多了一个功能:当用户输入一定字符后,自动完成文本框会显示一个下拉菜单,供 ...
- Android——控件AutoCompleteTextView 自动提示
Android:控件AutoCompleteTextView 自动提示 在输入框中输入我们想要输入的信息就会出现其他与其相关的提示信息,这种效果在Android中是用AutoCompleteTextV ...
- android适配器Adapter
一.什么是适配器,适配器有什么用? 适配器是AdapterView视图(如ListView - 列表视图控件.Gallery - 缩略图浏览器控件.GridView - 网格控件.Spinner - ...
随机推荐
- MySQL5.7.18基于GTID的主从复制过程实现
GTID是5.6时加入的,在5.7中被进一步完善,生产环境建议在5.7版本中使用.GTID全称为Global Transaction Identifiers,全局事务标识符.GTID的复制完全是基于事 ...
- CSS:使用CSS3将一个div水平和垂直居中显示
使用css3将一个div水平和垂直居中显示 方案一: div绝对定位水平垂直居中[margin:auto实现绝对定位元素的居中], 代码两个关键点:1.上下左右均0位置定位: 2.margin: au ...
- 【jQuery】页面顶部显示的进度条效果
<!Doctype html> <html> <head> <title>页面顶部显示的进度条效果</title> <meta htt ...
- bootstraptable toolbar
- Python学习笔记015——文件file的常规操作seek()及tell()
1 seek() 1.1 概述 file.seek()用于将文件游标移动到文件的任意位置,便于对文件的当前位置(增.删.改.查)操作 1.2 语法 fileObject.seek(offset[, w ...
- 订阅mosquitto服务器状态各主题
mosquitto_sub -v -t \$SYS/broker/client MQTT客户端可以通过订阅位于$SYS层次下的主题来查看mosquitto服务器的状态信息.标记为Static的主题对于 ...
- RHEL7 -- systemd
systemd 在RHEL7中,进程ID 1属于systemd这个新的进程.(代替之前版本中的init) systemd提供了以下新功能: ·并行化功能,可以提高系统的启动速度 ·按需启动守护进程,而 ...
- org.hibernate.MappingException: entity class not found hbm可以解析,但是实体类不能解析
在hbm.xml中给实体类加上包 com.we.lkl.studentVO
- 2-String to Integer (atoi)
实现atoi这个函数, public int atoi(String str),传入字符串str可以返回整数,请仔细考虑一下字符串的各种情况! String to Integer: Case分析 正常 ...
- Google大脑科学家贾杨清(Caffe缔造者)-微信讲座
Google大脑科学家贾杨清(Caffe缔造者)-微信讲座 机器学习Caffe 贾扬清 caffe 一.讲座正文: 大家好!我是贾扬清178,目前在Google Brain69,今天有幸受雷鸣师兄 ...