当前位置: 首页>>代码示例>>Java>>正文


Java IcsToast类代码示例

本文整理汇总了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();
            }
        });
    }
}
 
开发者ID:DroidPHP,项目名称:DroidPHP,代码行数:29,代码来源:AppController.java

示例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;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:31,代码来源:ActionMenuItemView.java


注:本文中的com.actionbarsherlock.internal.widget.IcsToast类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。