0
A
回答
0
创建一个自定义布局,您选择Toast
loook和感觉。
custom_toast.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_toast_layout_id"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF"
android:orientation="horizontal"
android:padding="5dp" >
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="5dp" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#000" />
</LinearLayout>
而且里面添加的onCreate下面这段代码()按钮点击
button = (Button) findViewById(R.id.buttonToast);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// get your custom_toast.xml ayout
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_toast,
(ViewGroup) findViewById(R.id.custom_toast_layout_id));
// set a dummy image
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.ic_launcher);
// set a message
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Button is clicked!");
// Toast...
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
});
当你点击按钮,您将看到自定义Toast
留言。
+0
永远欢迎buddy.Happy Coding :) –
0
要上的点击事件,它只是简单的自定义敬酒。 只是通过Android开发者网站去 - http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView%20
,或者你可以检查此样本吐司教程 - http://androiddesk.wordpress.com/2012/01/28/custom-notification-in-android-with-an-example/
相关问题
- 1. 的Android定制敬酒持续时间
- 2. Android中的敬酒
- 3. Android中的敬酒语
- 4. 旋转的Android敬酒
- 5. 敬酒与您的android?
- 6. Android的服务......让敬酒
- 7. Android敬酒投掷错误
- 8. Windows手机和Android敬酒
- 9. IllegalargumentException在Android中制作自定义敬酒时的问题
- 10. 显示使用Android的敬酒
- 11. Android的“敬酒”命令解释
- 12. 如何改变Android的敬酒
- 13. 对话后敬酒
- 14. Windows Phone上的多个预定敬酒
- 15. 如何在android中创建敬酒
- 16. 如何在ApplicationSyncAdapter Android中敬酒?
- 17. Android - 在视图下方显示敬酒?
- 18. Android课堂敬酒不工作?
- 19. 异步任务和敬酒 - Android
- 20. AndEngine场景中的敬酒
- 21. 敬酒不工作的WebView
- 22. 如何创建自定义敬酒
- 23. 在新线程中敬酒
- 24. 方向不敬酒视图
- 25. 如何长期敬酒?
- 26. 显示敬酒消息
- 27. 每天敬酒通知
- 28. WP7:如何显示敬酒?
- 29. Android动作酒吧定制
- 30. 的onclick给人以有线敬酒
http://stackoverflow.com/a/16909532/1752867这里有同样的问题和答案。 – KEYSAN
非常感谢你,我从这里得到了我所有的答案。 –
不客气。 – KEYSAN