2011-06-25 3 views
0

Ceci est un code de l'écran LockScreen dans android. Le dateformat est:Pourquoi je ne peux pas obtenir Settings.System.DATE_FORMAT dans le LockScreen?

mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year); 

Je tournai:

mDateFormatString =Settings.System.getString(getContext().getContentResolver(), Settings.System.DATE_FORMAT) ; 

Pourquoi je ne peux pas obtenir Settings.System.DATE_FORMAT dans le LockScreen?

private void resetStatusInfo(KeyguardUpdateMonitor updateMonitor) { 
    mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo(); 
    mPluggedIn = updateMonitor.isDevicePluggedIn(); 
    mBatteryLevel = updateMonitor.getBatteryLevel(); 

    /* for dual sim, by jing.wang */ 
    mStatus[SimCardID.ID_ZERO.toInt()] = getCurrentStatus(updateMonitor.getSimState()); 
    if (isDualMode) { 
     mStatus[SimCardID.ID_ONE.toInt()] = getCurrentStatus(updateMonitor.getSimState (SimCardID.ID_ONE)); 
     updateLayout(mStatus[SimCardID.ID_ZERO.toInt()], SimCardID.ID_ZERO, mStatus[SimCardID.ID_ONE.toInt()]); 
     updateLayout(mStatus[SimCardID.ID_ONE.toInt()], SimCardID.ID_ONE, mStatus[SimCardID.ID_ZERO.toInt()]); 
    } else { 
     updateLayout(mStatus[SimCardID.ID_ZERO.toInt()]); 
    } 

    refreshBatteryStringAndIcon(); 
    refreshAlarmDisplay(); 

    mTimeFormat = DateFormat.getTimeFormat(getContext()); 
    mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year); 

    refreshTimeAndDateDisplay(); 
    updateStatusLines(); 
} 

Edit: Je veux modifier le code de l'écran de verrouillage. Et je veux afficher le format de date que j'ai défini dans le paramètre. Mais maintenant, je définis le format de date "jj-MM-aaaa", il ne peut pas afficher dans l'écran de verrouillage. L'affichage de la date par le format de mDateFormatString.

mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year); 

Ceci est le code de refreshTimeAndDateDisplay.

private void refreshTimeAndDateDisplay() { 
    mDate.setText(DateFormat.format(mDateFormatString, new Date())); 
} 

Répondre

0

Vous devriez probablement regarder ceci: How to use the date format that has been setup as default in Settings? (getDateFormatOrder vous donne le réglage du format de l'utilisateur)

+0

public static final char [] getDateFormatOrder (contexte de contexte) depuis: API Niveau 3 Obtient le format de date stocké comme un tableau char. Le tableau contiendra 3 éléments (DATE, MONTH et YEAR) dans l'ordre spécifié par la préférence de format de l'utilisateur. – jackiezhou

+0

Pourriez-vous me dire comment modifier le code ????? – jackiezhou

+0

oui, si vous pouvez expliquer exactement ce que vous essayez de faire ... vous voulez modifier le code de l'écran de verrouillage? ou vous voulez faire quelque chose dans une application? – Matthieu

Questions connexes