android中Toast 的简单用法

原文地址:Toast 的简单用法 作者:老穆

1。原始版:

  Toast toast =Toast.makeText(getApplicationContext(),
     "自定义位置Toast",Toast.LENGTH_LONG);
   toast.setGravity(Gravity.CENTER,0, 0);  //importgravity
   toast.show();

2.带图片板:

toast =Toast.makeText(getApplicationContext(),
     "带图片的Toast",Toast.LENGTH_LONG);
   toast.setGravity(Gravity.CENTER,0, 0);
   LinearLayouttoastView = (LinearLayout) toast.getView();
   ImageViewimageCodeProject = newImageView(getApplicationContext());
   imageCodeProject.setImageResource(R.drawable.icon);
   toastView.addView(imageCodeProject,0);
   toast.show();

你可能感兴趣的:(toast)