private static Toast m_toast;
public static void showShortToast(Context context, String sText) {
showToast(context, sText, Toast.LENGTH_SHORT);
}
public static void showShortToast(Context context, int nResId) {
showToast(context, nResId, Toast.LENGTH_SHORT);
}
public static void showLongToast(Context context, String sText) {
showToast(context, sText, Toast.LENGTH_LONG);
}
public static void showLongToast(Context context, int nResId) {
showToast(context, nResId, Toast.LENGTH_LONG);
}
private static void showToast(Context context, String sText, int nDuration) {
if(m_toast == null) {
m_toast = Toast.makeText(context, "", nDuration);
}
m_toast.setText(sText);
m_toast.setDuration(nDuration);
m_toast.setGravity(Gravity.CENTER, 0, 0);
m_toast.show();
}
private static void showToast(Context context, int nResId, int nDuration) {
if(m_toast == null) {
m_toast = Toast.makeText(context, "", nDuration);
}
m_toast.setText(nResId);
m_toast.setDuration(nDuration);
m_toast.setGravity(Gravity.CENTER, 0, 0);
m_toast.show();
}
'프로그래밍 > Android' 카테고리의 다른 글
Android File folder delete (0) | 2014.11.23 |
---|---|
Android System Bar Hide (0) | 2014.11.15 |
Android ListView 아이템과 Button 이벤트를 각각 처리하는 방법 (0) | 2014.11.02 |
Android Actionbar(appcompat_v7) 사용하기 (0) | 2014.11.01 |
Android BaseAdapter (0) | 2014.04.17 |
댓글