Android Studio 基础知识总结(Spinning,button........)
strings.xml :字符文件中定义字符等等数组,用于spinner,下拉列表
一、spinner
<!--使用string——array 和item 两个标签-->
<string-array name="language"><item>fast</item> <item>easy</item><item>new</item><item>OO</item></string-array>
然后在spinner中的entries
属性:绑定@array/数组名字
<Spinnerandroid:layout_width="match_parent"android:layout_height="match_parent"android:entries="@array/language"></Spinner>
获取用户界面spinner的选项:
// 获得spinner的引用Spinner spinner = findViewById(R.id.feature);
// 获得spinner的选项String feature = spinner.getSelectedItem().toString();
new静态的对象:
private final yyyy xxxx new yyyy对象;
// 列如:private final ProgramExpert expert = new ProgramExpert();
之后直接可以使用,xxx对象调用方法
// 查询语句函数(后端模型层)String result = expert.getLanguage(feature);
二、TextView的使用
// 获得TextView的引用TextView textview = findViewById(R.id.language);textview.setText(result);
三、两个activity的发送信息,使用的intent
- 发送方
// 获取编辑框的引用TextView input = findViewById(R.id.input);
// 获取编辑框的内容String message = input.getText().toString();//com.example.message 为接受方所在包名public static final String MESSAGE_KEY = "com.example.message";// 与另外一个activity建立协议联系Intent intent = new Intent(this, ReceiveMessageActivity.class);
// 在intent中附加消息文字intent.putExtra(MESSAGE_KEY,message);
// 建立连接startActivity(intent);
1.ReceiveMessageActivity.class 为接收方main+默认classs
2. “com.example.message” 为接受方所在包名
3. message 为消息内容
- 接收方
// 获取intent的引用Intent intent = getIntent();
// 去除连接之间的文字信息String message = intent.getStringExtra(CreateMessageActivity.MESSAGE_KEY);
// 界面文字的设置TextView textView = findViewById(R.id.output);textView.setText(message);
- getStringExtra(CreateMessageActivity.MESSAGE_KEY); 中 getStringExtra 还用getIntExtra等方法,具体的方法参数不同,MESSAGE_KEY:设置为public类型,CreateMessageActivity:发送方的main,其实就是知道发送的信息
我理解的:发送肯定要知道发给谁啊,接受知道接受谁的
Android Studio 基础知识总结(Spinning,button........)相关推荐
- android studio 画控件,Android Studio 基础控件使用
TextView android:gravity="center" //文字对其方式 top bottom left right center android:textColor= ...
- Android Studio基础单选按钮RadioButton
Android Studio基础单选按钮RadioButton 1.单选按钮RadioButton:多个只能选择一个,必须结合RadioGroup控件使用,才能实现单选的特性. 第一种情况:没有结合R ...
- Android Studio 基础 之 截图,指定截图区域动态截图
Android Studio 基础 之 截图,指定截图区域动态截图 目录 Android Studio 基础 之 截图,指定截图区域动态截图 一.简单介绍 二.实现原理 三.注意事项 四.预览效果 五 ...
- Android Studio 基础 之 获取系统Calendar 日历日程(可获得当天以后可设定天数范围内的日历日程) (涉及指定日期时间判断是星期几的方法使用)的方法整理
Android Studio 基础 之 获取系统Calendar 日历日程(可获得当天以后可设定天数范围内的日历日程) (涉及指定日期时间判断是星期几的方法使用)的方法整理 目录 Android St ...
- Android Studio 基础按钮使用
Android Studio 基础按钮使用 按钮使用线性的垂直布局 更改默认按钮的深蓝色背景(https://blog.csdn.net/try17875864815/article/details/ ...
- Android Studio 基础 之 获取蓝牙Bluetooth 的状态,设置的蓝牙Bluetooth 的开关状态,并监听蓝牙Bluetooth 的状态变化方法整理
Android Studio 基础 之 获取蓝牙Bluetooth 的状态,设置的蓝牙Bluetooth 的开关状态,并监听蓝牙Bluetooth 的状态变化方法整理 目录 Android Studi ...
- Android Studio基础输入文本框EditText
Android Studio基础输入文本框EditText 接续上一节<Android Studio 基础按钮使用> 1.提示文本框.输入文本框,在布局xml编写 <EditText ...
- Android Studio 基础 之 简单获取手机端所有图片
Android Studio 基础 之 简单获取手机端所有图片 目录 Android Studio 基础 之 简单获取手机端所有图片 一.简单介绍 二.实现原理 三.注意实现 四.预览效果 五.实现步 ...
- 日历 android 周历,Android Studio 基础 之 获取系统Calendar 日历日程 (涉及指定日期时间判断是星期几的方法使用)的方法整理...
Android Studio 基础 之 获取系统Calendar 日历日程 (涉及指定日期时间判断是星期几的方法使用)的方法整理 目录 Android Studio 基础 之 获取系统Calendar ...
最新文章
- CFtpFileFind FindFile卡住的问题
- WCF:Maximum number of items that can be serialized or deserialized in an object graph is '65536'.
- java中ThreadLocalRandom的使用
- Writing your first Django app--Django 第一步
- async 与 await 的用法详解
- C#随机生成信用卡卡号的源码
- mysql 数据库和实例_mysql中数据库和数据库实例的概念区别
- SQL-SELECT 语句,From子句,where条件查询
- RAID - 提升IO性能及数据安全
- tf.keras计算FLOPs
- 收藏的博客 -- Qt有关的GitHub/Gitee开源项目
- php 生成ics文件
- upc 7834 送礼物
- react仿微信聊天室|react即时聊天IM系统|react群聊
- RNNoise超详细解析
- Layer For Mobile
- 【web安全学习篇1】VBS脚本基础编写总结
- 【自建NAS】Ubuntu Server 配置 WIFI 连接
- oracle的表的数据管理2 -- 基本查询
- Maltab GUI课程设计——网络爬虫程序(基金连涨连跌提醒)