首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Toast 的几种展示方法

2012-06-26 
Toast 的几种显示方法Toast toast new Toast(this) ImageView view new ImageView(this) view.setIm

Toast 的几种显示方法

Toast toast = new Toast(this); ImageView view = new ImageView(this); view.setImageResource(R.drawable.icon); toast.setView(view); toast.show();//第二种图片加文字Toast toast = Toast.makeText(this, "lalalal", Toast.LENGTH_LONG); View textView = toast.getView(); LinearLayout lay = new LinearLayout(this); lay.setOrientation(LinearLayout.HORIZONTAL); ImageView view = new ImageView(this); view.setImageResource(R.drawable.icon); lay.addView(view); lay.addView(textView); toast.setView(lay); toast.show();//自定义位置LayoutInflater inflater = getLayoutInflater();   View layout = inflater.inflate(R.layout.custom,     (ViewGroup) findViewById(R.id.llToast));   ImageView image = (ImageView) layout     .findViewById(R.id.tvImageToast);   image.setImageResource(R.drawable.icon);   TextView title = (TextView) layout.findViewById(R.id.tvTitleToast);   title.setText("Attention");   TextView text = (TextView) layout.findViewById(R.id.tvTextToast);   text.setText("自定义Toast");   toast = new Toast(getApplicationContext());   toast.setGravity(Gravity.RIGHT | Gravity.TOP, 12, 40);   toast.setDuration(Toast.LENGTH_LONG);   toast.setView(layout);   toast.show();

热点排行