AdMob不使用IF声明?

时间:2012-07-11 14:19:25

标签: if-statement locale admob advertisement

此代码不起作用。我检查了 displayLanguage 值。价值是正确的( displayLanguage =“Türkçe”)。但它不起作用。

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());

}

我不明白问题是什么。

2 个答案:

答案 0 :(得分:1)

这不是AdMob问题。但试试这个:

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

答案 1 :(得分:0)

我解决了问题。这对我有用:

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