当前位置:网站首页>Toast will display a simple prompt message on the program interface
Toast will display a simple prompt message on the program interface
2022-07-07 17:36:00 【XLMN】
toast A simple prompt message will be displayed on the program interface
This information prompt box is used to generate simple prompt messages for users , It has the following characteristics
1、toast Prompt messages will not live in focus
2、toast The prompt message will disappear automatically after a period of time
send total Method of generating prompt message
1、 call toast Constructor , or maketext() The static method creates one total object
2、 call toast Method to set the alignment of the message prompt , Margins, etc
3、 call toast Of show Method to show him
total The function and usage are relatively simple , Generally, simple text prompt information is displayed , If you need to display something like a picture , Complex tips like lists , It is generally recommended to use dialog boxes to complete , Or use toast Construction example , Calling setview Method to set the toast According to the view Components
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.bt);
Button bt = (Button) findViewById(R.id.bt01);
bt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
// Create a toast Prompt information Toast.LENGTH_LONG) Prompt information time
Toast ts = Toast.makeText(MainActivity.this, " I wish you a happy and bitter day , Mountains, rivers, stars and moon all make congratulatory gifts ",
Toast.LENGTH_LONG);
ts.show();
}
});
Button bt1 = (Button) findViewById(R.id.bt02);
// Set the prompt message with picture
bt1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
// Create a total Prompt information
Toast ts = new Toast(MainActivity.this);
// Set the prompt display position
ts.setGravity(Gravity.CENTER, 0, 0);
// Create a imageview
ImageView image = new ImageView(MainActivity.this);
image.setImageResource(R.drawable.love);
// Create a linearlayout Containers
LinearLayout ly = new LinearLayout(MainActivity.this);
// Add pictures and original... To the container view
ly.addView(image);
// Create a textview
TextView tv = new TextView(MainActivity.this);
tv.setText("love mia");
// Set the size and font color of the text box
tv.setTextSize(24);
tv.setTextColor(Color.MAGENTA);
ly.addView(tv);
// Set display custom view
ts.setView(ly);
// Set up toast Display time
ts.setDuration(Toast.LENGTH_LONG);
ts.show();
}
});
}
}

边栏推荐
- serachview的功能和用法
- Siggraph 2022 best technical paper award comes out! Chen Baoquan team of Peking University was nominated for honorary nomination
- [video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
- 【网络攻防原理与技术】第4章:网络扫描技术
- 2021-06-28
- 如何在软件研发阶段落地安全实践
- Smart logistics platform: make overseas warehouses smarter
- 【TPM2.0原理及应用指南】 1-3章
- 自定义View必备知识,Android研发岗必问30+道高级面试题
- With the latest Alibaba P7 technology system, mom doesn't have to worry about me looking for a job anymore
猜你喜欢

请将磁盘插入“U盘(H)“的情况&无法访问 磁盘结构损坏且无法读取

第3章业务功能开发(用户登录)

简单的loading动画

DevOps 的运营和商业利益指南

【TPM2.0原理及应用指南】 16、17、18章

What is cloud computing?

Nerf: the ultimate replacement for deepfake?

DatePickerDialog和trimepickerDialog

麒麟信安中标国网新一代调度项目!
![[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial](/img/14/4e7ebfb1ed5b99f8377af9d17d2177.jpg)
[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
随机推荐
LeetCode 497(C#)
Sator推出Web3遊戲“Satorspace” ,並上線Huobi
The top of slashdata developer tool is up to you!!!
国内首创!Todesk将RTC技术融入远程桌面,画质更清晰操作更流畅
状态模式 - Unity(有限状态机)
【可信计算】第十一次课:TPM密码资源管理(三) NV索引与PCR
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
mysql官网下载:Linux的mysql8.x版本(图文详解)
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
在窗口上面显示进度条
LeetCode刷题day49
toast会在程序界面上显示一个简单的提示信息
【可信计算】第十次课:TPM密码资源管理(二)
LeetCode 648(C#)
智慧物流平台:让海外仓更聪明
阿富汗临时政府安全部队对极端组织“伊斯兰国”一处藏匿点展开军事行动
L1-028 判断素数(Lua)
无法链接远程redis服务器(解决办法百分百)
centos7安装mysql笔记
Nerf: the ultimate replacement for deepfake?