Toasts
来源:互联网 发布:2016年宏观经济数据 编辑:程序博客网 时间:2024/06/06 10:03
简单的Toast:Toast.makeText(getApplicationContext(), "some message", Toast.LENGTH_SHORT).show();
还可以设置Toast出现的位置:toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.show();
自定义Toast
首先我们先定义一个布局文件toast_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toast_layout_root"> <ImageView android:src="@drawable/droid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dp" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFF" /></LinearLayout>
在javadiamagnetic中设置:
private void displayToast(String message) { // 加载布局文件 View layout = getLayoutInflater().inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root)); // 向toast中填入信息 TextView text = (TextView) layout.findViewById(R.id.text); text.setText(message); // Construct the toast, set the view and display Toast toast = Toast.makeText(getApplicationContext(), "some message", Toast.LENGTH_SHORT); toast.setView(layout); toast.show();}
0 0
- Toasts
- Toasts
- android Toasts
- android - Toasts
- 【3】Toasts
- 自定义Android Toasts风格
- 自定义Android Toasts风格
- Toasts(提示框)
- Android API Guides---Toasts
- API Guides——Toasts
- 时间、日期、Toasts和进度条Dialog
- Android开发总结笔记 Toasts(吐司泡) 1-1-17
- Android UI系列-----时间、日期、Toasts和进度条Dialog
- Hust oj 1384 Leyni, LOLI and Toasts(水题)
- Android UI系列中的Dialog,包括DatePickerDialog、TimePickerDialog、Toasts以及ProgressDialog
- 一道有趣的面试题
- could not resolve xxx
- treeTable jquery的树表组件 java实现 Java实现树形菜单
- 使用Hive读取Hbase中的数据
- 【YMGJ 4】APP-----长度不能小于 0
- Toasts
- Codeforces 570B Simple Game
- ubuntu中spark使用mysql 图文教程
- Oracle clob无法修改为blob
- 练习5-15 增加选项-f,使得排序过程不考虑字母大小写之间的区别。例如比较a和A时认为它们相等
- Elementary OS 下安装 ROS (Robot Operating System)
- ListView的HeaderView
- 天线设计(上)
- 21. Merge Two Sorted Lists