Toast用法
来源:互联网 发布:如何做好淘宝众筹 编辑:程序博客网 时间:2024/05/16 11:18
Toast是Android专属的提示小对象,一个简短的小信息,将要告诉用户的信息以一个浮动在最上层的View显示。显示Toast后,静待几秒就会消失,最常见的应用是音量大小的调整。
main.xml
<EditText android:id="@+id/myEditText" android:layout_width="fill_parent" android:layout_height="50px" android:textSize="20dip" ></EditText> <Button android:id="@+id/myButton" android:layout_width="60px" android:layout_height="50px" android:text="送出愿望"></Button>
activity
public class Ex04_03 extends Activity { /** Called when the activity is first created. */private Button mButton;private EditText mEditText; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mButton = (Button)findViewById(R.id.myButton); mEditText = (EditText)findViewById(R.id.myEditText); mButton.setOnClickListener(new mButtonClickListener()); } class mButtonClickListener implements OnClickListener {@Overridepublic void onClick(View v) {// TODO Auto-generated method stub//声明字符串变量并取得用户的EditText的字符串Editable str;str = mEditText.getText();//使用系统标准的makeText()方式产生Toast信息Toast.makeText(Ex04_03.this, "你的愿望:"+str.toString()+"已送达圣诞老人信箱",Toast.LENGTH_LONG).show();mEditText.setText("");} }}
效果
当然也可以通过重写Toast对象的方法,自定义Toast显示的Layout,
- Toast用法
- Toast用法
- Toast用法
- Toast用法
- Toast用法
- Toast用法
- Toast用法
- toast用法
- Toast用法!!
- android-Toast的用法
- Android Toast用法
- Toast 的用法
- 【android】Toast用法总结
- Android Toast 的用法
- Android Toast 用法总结
- Toast.makeText用法
- Toast的简单用法
- Toast的基本用法
- Spring总结-----@Component,@Service,@Controller,@Repository
- 从系统调用nanosleep()学习High-Resolution Timers
- 自学PHP的笔记(六)注释标记数组排序
- 川田工业开发出可和人类协作的人形机器人
- js eval() 全局作用域(真是好文章),解决了大问题
- Toast用法
- android 网络获取图片并存储
- 为什么“裤裆文学”和“丑星”走俏?
- Linux平台下的service程序编写指南
- jvm
- Command模式
- Using color in Android, by XML
- asp.net 导出 excel
- 利用DLL制作多语言版软件