當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。