Methods Summary |
---|
public void | cancel()Close the view if it's showing, or don't show it if it isn't showing yet.
You do not normally have to call this. Normally view will disappear on its own
after the appropriate duration.
mTN.hide();
try {
getService().cancelToast(mContext.getPackageName(), mTN);
} catch (RemoteException e) {
// Empty
}
|
public int | getDuration()Return the duration.
return mDuration;
|
public int | getGravity()Get the location at which the notification should appear on the screen.
return mTN.mGravity;
|
public float | getHorizontalMargin()Return the horizontal margin.
return mTN.mHorizontalMargin;
|
private static android.app.INotificationManager | getService()
if (sService != null) {
return sService;
}
sService = INotificationManager.Stub.asInterface(ServiceManager.getService("notification"));
return sService;
|
public float | getVerticalMargin()Return the vertical margin.
return mTN.mVerticalMargin;
|
public android.view.View | getView()Return the view.
return mNextView;
|
public WindowManager.LayoutParams | getWindowParams()Gets the LayoutParams for the Toast window.
return mTN.mParams;
|
public int | getXOffset()Return the X offset in pixels to apply to the gravity's location.
return mTN.mX;
|
public int | getYOffset()Return the Y offset in pixels to apply to the gravity's location.
return mTN.mY;
|
public static android.widget.Toast | makeText(android.content.Context context, java.lang.CharSequence text, int duration)Make a standard toast that just contains a text view.
Toast result = new Toast(context);
LayoutInflater inflate = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflate.inflate(com.android.internal.R.layout.transient_notification, null);
TextView tv = (TextView)v.findViewById(com.android.internal.R.id.message);
tv.setText(text);
result.mNextView = v;
result.mDuration = duration;
return result;
|
public static android.widget.Toast | makeText(android.content.Context context, int resId, int duration)Make a standard toast that just contains a text view with the text from a resource.
return makeText(context, context.getResources().getText(resId), duration);
|
public void | setDuration(int duration)Set how long to show the view for.
mDuration = duration;
|
public void | setGravity(int gravity, int xOffset, int yOffset)Set the location at which the notification should appear on the screen.
mTN.mGravity = gravity;
mTN.mX = xOffset;
mTN.mY = yOffset;
|
public void | setMargin(float horizontalMargin, float verticalMargin)Set the margins of the view.
mTN.mHorizontalMargin = horizontalMargin;
mTN.mVerticalMargin = verticalMargin;
|
public void | setText(int resId)Update the text in a Toast that was previously created using one of the makeText() methods.
setText(mContext.getText(resId));
|
public void | setText(java.lang.CharSequence s)Update the text in a Toast that was previously created using one of the makeText() methods.
if (mNextView == null) {
throw new RuntimeException("This Toast was not created with Toast.makeText()");
}
TextView tv = (TextView) mNextView.findViewById(com.android.internal.R.id.message);
if (tv == null) {
throw new RuntimeException("This Toast was not created with Toast.makeText()");
}
tv.setText(s);
|
public void | setView(android.view.View view)Set the view to show.
mNextView = view;
|
public void | show()Show the view for the specified duration.
if (mNextView == null) {
throw new RuntimeException("setView must have been called");
}
INotificationManager service = getService();
String pkg = mContext.getOpPackageName();
TN tn = mTN;
tn.mNextView = mNextView;
try {
service.enqueueToast(pkg, tn, mDuration);
} catch (RemoteException e) {
// Empty
}
|