本文整理匯總了Java中com.actionbarsherlock.internal.widget.IcsToast類的典型用法代碼示例。如果您正苦於以下問題:Java IcsToast類的具體用法?Java IcsToast怎麽用?Java IcsToast使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IcsToast類屬於com.actionbarsherlock.internal.widget包,在下文中一共展示了IcsToast類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toast
import com.actionbarsherlock.internal.widget.IcsToast; //導入依賴的package包/類
/**
* Shows a toast message
*
* @param context Any context belonging to this application
* @param message The message to show
*/
public static void toast(Context context, String message) {
// this is a static method so it is easier to call,
// as the context checking and casting is done for you
if (context == null) return;
if (!(context instanceof Application)) {
context = context.getApplicationContext();
}
if (context instanceof Application) {
final Context c = context;
final String m = message;
((AppController) context).runInApplicationThread(new Runnable() {
@Override
public void run() {
IcsToast.makeText(c, m, IcsToast.LENGTH_LONG).show();
}
});
}
}
示例2: onLongClick
import com.actionbarsherlock.internal.widget.IcsToast; //導入依賴的package包/類
@Override
public boolean onLongClick(View v) {
if (hasText()) {
// Don't show the cheat sheet for items that already show text.
return false;
}
final int[] screenPos = new int[2];
final Rect displayFrame = new Rect();
getLocationOnScreen(screenPos);
getWindowVisibleDisplayFrame(displayFrame);
final Context context = getContext();
final int width = getWidth();
final int height = getHeight();
final int midy = screenPos[1] + height / 2;
final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
Toast cheatSheet = IcsToast.makeText(context, mItemData.getTitle(), IcsToast.LENGTH_SHORT);
if (midy < displayFrame.height()) {
// Show along the top; follow action buttons
cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT,
screenWidth - screenPos[0] - width / 2, height);
} else {
// Show along the bottom center
cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
}
cheatSheet.show();
return true;
}