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();
// TODO this still needs to cancel the inflight notification if any
|
public int | getDuration()Return the duration.
return mDuration;
|
public int | getGravity()Get the location at which the notification should appear on the screen.
return mGravity;
|
public float | getHorizontalMargin()Return the horizontal margin.
return 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 mVerticalMargin;
|
public android.view.View | getView()Return the view.
return mNextView;
|
public int | getXOffset()Return the X offset in pixels to apply to the gravity's location.
return mX;
|
public int | getYOffset()Return the Y offset in pixels to apply to the gravity's location.
return 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.
mGravity = gravity;
mX = xOffset;
mY = yOffset;
|
public void | setMargin(float horizontalMargin, float verticalMargin)Set the margins of the view.
mHorizontalMargin = horizontalMargin;
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.getPackageName();
TN tn = mTN;
try {
service.enqueueToast(pkg, tn, mDuration);
} catch (RemoteException e) {
// Empty
}
|