本文整理汇总了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;
}