2012-07-11 87 views
0

此代碼不起作用。我查了displayLanguage的值。價值是正確的(displayLanguage =「Türkçe」)。但它不起作用。AdMob不使用IF語句?

private void setAdvertisement() 
{ 

Locale _locale = Locale.getDefault(); 
String displayLanguage = _locale.getDisplayLanguage(); 
if(displayLanguage == "Türkçe") 
{ 
    // Create the adView 
    adView = new AdView(this, AdSize.BANNER, "My Admob ID"); 

    // Lookup your LinearLayout assuming it’s been given 
    // the attribute android:id="@+id/mainLayout" 


    // Add the adView to it 
    linearLayoutAdvertisement.addView(adView); 

    // Initiate a generic request to load it with an ad 
    adView.loadAd(new AdRequest()); 
} 
} 

但這個代碼工作正常:

private void setAdvertisement() 
{ 
     // Create the adView 
     adView = new AdView(this, AdSize.BANNER, "My Admob ID"); 

     // Lookup your LinearLayout assuming it’s been given 
     // the attribute android:id="@+id/mainLayout" 


     // Add the adView to it 
     linearLayoutAdvertisement.addView(adView); 

     // Initiate a generic request to load it with an ad 
     adView.loadAd(new AdRequest()); 

} 

我不明白是什麼問題。

回答

1

這不是AdMob問題。但試試這個:

if ("Türkçe".equals(displayLanguage)) { 
    .. 
} 
0

我解決了問題。這工作對我來說:

if(Locale.getDefault().getLanguage().equals("tr")) 
    { 
     ... 
    }