问:
Unable to see the both banner and interstitial ads in libgdx framework?
This one was the original code without comments

```<code>import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.gamestudio24.martianrun.MartianRun;
import com.gamestudio24.martianrun.utils.Constants;
import com.gamestudio24.martianrun.utils.GameEventListener;
import com.gamestudio24.martianrun.utils.GameManager;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.games.Games;
import com.google.games.basegameutils.GameHelper;

public class AndroidLauncher extends AndroidApplication implements GameHelper.GameHelperListener,
        GameEventListener {

    private static String SAVED_LEADERBOARD_REQUESTED = "SAVED_LEADERBOARD_REQUESTED";
    private static String SAVED_ACHIEVEMENTS_REQUESTED = "SAVED_ACHIEVEMENTS_REQUESTED";

    private GameHelper gameHelper;

    private AdView mAdView;
    private boolean mLeaderboardRequested;
    private boolean mAchievementsRequested;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create the layout
        RelativeLayout layout = new RelativeLayout(this);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

        // Game view
        View gameView = initializeForView(new MartianRun(this), config);
        layout.addView(gameView);

        mAdView = createAdView();
        mAdView.loadAd(createAdRequest());

        layout.addView(mAdView, getAdParams());

        setContentView(layout);

        gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
        gameHelper.setup(this);
        gameHelper.setMaxAutoSignInAttempts(0);
    }

    @Override
    protected void onStart() {
        super.onStart();
        gameHelper.onStart(this);
        GoogleAnalytics.getInstance(this).reportActivityStart(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        gameHelper.onStop();
        GoogleAnalytics.getInstance(this).reportActivityStop(this);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        gameHelper.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putBoolean(SAVED_LEADERBOARD_REQUESTED, mLeaderboardRequested);
        outState.putBoolean(SAVED_ACHIEVEMENTS_REQUESTED, mAchievementsRequested);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        mLeaderboardRequested = savedInstanceState.getBoolean(SAVED_LEADERBOARD_REQUESTED, false);
        mAchievementsRequested = savedInstanceState.getBoolean(SAVED_ACHIEVEMENTS_REQUESTED, false);
    }

    private AdRequest createAdRequest() {
        return new AdRequest.Builder()
                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice("461B8D3A7843CE98FD0EBD0917030589")
                .build();

    }

    private AdView createAdView() {
        AdView adView = new AdView(this);

        adView.setAdSize(AdSize.SMART_BANNER);
        adView.setAdUnitId(getAdMobUnitId());

        return adView;
    }

    private RelativeLayout.LayoutParams getAdParams() {
        RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);

        adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

        return adParams;
    }

    @Override
    public void onSignInFailed() {
        // handle sign-in failure (e.g. show Sign In button)
        mLeaderboardRequested = false;
        mAchievementsRequested = false;
    }

    @Override
    public void onSignInSucceeded() {
        // handle sign-in success
        if (GameManager.getInstance().hasSavedMaxScore()) {
            GameManager.getInstance().submitSavedMaxScore();
        }

        if (mLeaderboardRequested) {
            displayLeaderboard();
            mLeaderboardRequested = false;
        }

        if (mAchievementsRequested) {
            displayAchievements();
            mAchievementsRequested = false;
        }
    }

    @Override
    public void displayAd() {
        mAdView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideAd() {
        mAdView.setVisibility(View.GONE);
    }

    @Override
    public void submitScore(int score) {
        if (gameHelper.isSignedIn()) {
            Games.Leaderboards.submitScore(gameHelper.getApiClient(),
                    getString(R.string.leaderboard_high_scores), score);
        } else {
            GameManager.getInstance().saveScore(score);
        }
    }

    @Override
    public void displayLeaderboard() {
        if (gameHelper.isSignedIn()) {
            startActivityForResult(Games.Leaderboards.getLeaderboardIntent(gameHelper.getApiClient(),
                    getString(R.string.leaderboard_high_scores)), 24);
        } else {
            gameHelper.beginUserInitiatedSignIn();
            mLeaderboardRequested = true;
        }
    }

    @Override
    public void displayAchievements() {
        if (gameHelper.isSignedIn()) {
            startActivityForResult(
                    Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 25);
        } else {
            gameHelper.beginUserInitiatedSignIn();
            mAchievementsRequested = true;
        }
    }

    @Override
    public void share() {
        String url = String.format(" ",
                BuildConfig.APPLICATION_ID);
        String message = String.format(Constants.SHARE_MESSAGE_PREFIX, url);
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("text/plain");
        share.putExtra(Intent.EXTRA_TEXT, message);
        startActivity(Intent.createChooser(share, Constants.SHARE_TITLE));
    }

    @Override
    public void unlockAchievement(String id) {
        if (gameHelper.isSignedIn()) {
            Games.Achievements.unlock(gameHelper.getApiClient(), id);
            GameManager.getInstance().setAchievementUnlocked(id);
        }
    }

    @Override
    public void incrementAchievement(String id, int steps) {
        if (gameHelper.isSignedIn()) {
            Games.Achievements.increment(gameHelper.getApiClient(), id, steps);
            GameManager.getInstance().incrementAchievementCount(id, steps);
        }
    }

    @Override
    public String getGettingStartedAchievementId() {
        return getString(R.string.achievement_getting_started);
    }

    @Override
    public String getLikeARoverAchievementId() {
        return getString(R.string.achievement_like_a_rover);
    }

    @Override
    public String getSpiritAchievementId() {
        return getString(R.string.achievement_spirit);
    }

    @Override
    public String getCuriosityAchievementId() {
        return getString(R.string.achievement_curiosity);
    }

    @Override
    public String get5kClubAchievementId() {
        return getString(R.string.achievement_5k_club);
    }

    @Override
    public String get10kClubAchievementId() {
        return getString(R.string.achievement_10k_club);
    }

    @Override
    public String get25kClubAchievementId() {
        return getString(R.string.achievement_25k_club);
    }

    @Override
    public String get50kClubAchievementId() {
        return getString(R.string.achievement_50k_club);
    }

    @Override
    public String get10JumpStreetAchievementId() {
        return getString(R.string.achievement_10_jump_street);
    }

    @Override
    public String get100JumpStreetAchievementId() {
        return getString(R.string.achievement_100_jump_street);
    }

    @Override
    public String get500JumpStreetAchievementId() {
        return getString(R.string.achievement_500_jump_street);
    }

    private String getAdMobUnitId() {
        return getString(R.string.ad_unit_id);
    }
</code>```

This errors occurs when to generate the ads on libgdx game

07-04 11:57:44.181 8773-8773/com.gamestudio24.cityescape.android D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
    07-04 11:57:44.301 8773-8773/com.gamestudio24.cityescape.android I/Ads: Starting ad request.
    07-04 11:57:44.301 8773-8773/com.gamestudio24.cityescape.android I/Ads: Use AdRequest.Builder.addTestDevice("461B8D3A7843CE98FD0EBD0917030589") to get test ads on this device.
    07-04 11:57:47.971 8773-8773/com.gamestudio24.cityescape.android I/Ads: Ad finished loading.

```<code>            import android.content.Intent;
            import android.os.Bundle;
            import android.view.View;
            import android.view.Window;
            import android.view.WindowManager;
            import android.widget.RelativeLayout;
            import com.badlogic.gdx.backends.android.AndroidApplication;
            import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
            import com.gamestudio24.martianrun.MartianRun;
            import com.gamestudio24.martianrun.utils.Constants;
            import com.gamestudio24.martianrun.utils.GameEventListener;
            import com.gamestudio24.martianrun.utils.GameManager;
            import com.google.android.gms.ads.AdListener;
            import com.google.android.gms.ads.AdRequest;
            import com.google.android.gms.ads.AdSize;
            import com.google.android.gms.ads.AdView;
            import com.google.android.gms.ads.InterstitialAd;
            import com.google.android.gms.ads.MobileAds;
            import com.google.android.gms.analytics.GoogleAnalytics;
            import com.google.android.gms.games.Games;
            import com.google.games.basegameutils.GameHelper;

            public class AndroidLauncher extends AndroidApplication implements GameHelper.GameHelperListener,
                    GameEventListener {

                private static String SAVED_LEADERBOARD_REQUESTED = "SAVED_LEADERBOARD_REQUESTED";
                private static String SAVED_ACHIEVEMENTS_REQUESTED = "SAVED_ACHIEVEMENTS_REQUESTED";

                private GameHelper gameHelper;
                private InterstitialAd mInterstitialAd;

                private AdView mAdView;
                private boolean mLeaderboardRequested;
                private boolean mAchievementsRequested;

                @Override
                protected void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);

                    // Create the layout
                    RelativeLayout layout = new RelativeLayout(this);
                    MobileAds.initialize(this,"ca-app-pub-3940256099942544/1033173712");

                    requestWindowFeature(Window.FEATURE_NO_TITLE);
                    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
                    getWindow().clearFlags(
                            WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

                    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

                    // Game view
                    View gameView = initializeForView(new MartianRun(this), config);
                    layout.addView(gameView);

                    mAdView = createAdView();
                   // mAdView.loadAd(createAdRequest());

                    layout.addView(mAdView, getAdParams());

                    setContentView(layout);

                    gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
                    gameHelper.setup(this);
                    gameHelper.setMaxAutoSignInAttempts(0);
                }

                @Override
                protected void onStart() {
                    super.onStart();
                    gameHelper.onStart(this);
                    GoogleAnalytics.getInstance(this).reportActivityStart(this);
                }

                @Override
                protected void onStop() {
                    super.onStop();
                    gameHelper.onStop();
                    GoogleAnalytics.getInstance(this).reportActivityStop(this);
                }

                @Override
                protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                    super.onActivityResult(requestCode, resultCode, data);
                    gameHelper.onActivityResult(requestCode, resultCode, data);
                }

                @Override
                protected void onSaveInstanceState(Bundle outState) {
                    super.onSaveInstanceState(outState);
                    outState.putBoolean(SAVED_LEADERBOARD_REQUESTED, mLeaderboardRequested);
                    outState.putBoolean(SAVED_ACHIEVEMENTS_REQUESTED, mAchievementsRequested);
                }

                @Override
                protected void onRestoreInstanceState(Bundle savedInstanceState) {
                    super.onRestoreInstanceState(savedInstanceState);
                    mLeaderboardRequested = savedInstanceState.getBoolean(SAVED_LEADERBOARD_REQUESTED, false);
                    mAchievementsRequested = savedInstanceState.getBoolean(SAVED_ACHIEVEMENTS_REQUESTED, false);
                }

            //        AdRequest adRequest = new AdRequest.Builder()
            //                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            //                .build();

        // I want to show here banner and interstitial ads but its not show what to do for that because i declare banner ad unit id in string.xml and interestitial ad unit id in this android launcher
                private AdView createAdView() {
                    AdView adView = new AdView(this);
                    adView.setAdSize(AdSize.SMART_BANNER);
                    adView.setAdUnitId(getAdMobUnitId());
                    mInterstitialAd = new InterstitialAd(this);
                    mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
                    mInterstitialAd.loadAd(new AdRequest.Builder().build());
                    mInterstitialAd.setAdListener(new AdListener() {
                        @Override
                        public void onAdClosed() {
                            super.onAdClosed();
                        }
                    });

                    return adView;
                }

                private RelativeLayout.LayoutParams getAdParams() {
                    AdRequest.Builder builder = new AdRequest.Builder();
                    builder.addTestDevice(" ");
                    RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                            RelativeLayout.LayoutParams.MATCH_PARENT,
                            RelativeLayout.LayoutParams.WRAP_CONTENT);

                    adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

                    return adParams;
                }

                @Override
                public void onSignInFailed() {
                    // handle sign-in failure (e.g. show Sign In button)
                    mLeaderboardRequested = false;
                    mAchievementsRequested = false;
                }

                @Override
                public void onSignInSucceeded() {
                    // handle sign-in success
                    if (GameManager.getInstance().hasSavedMaxScore()) {
                        GameManager.getInstance().submitSavedMaxScore();
                    }

                    if (mLeaderboardRequested) {
                        displayLeaderboard();
                        mLeaderboardRequested = false;
                    }

                    if (mAchievementsRequested) {
                        displayAchievements();
                        mAchievementsRequested = false;
                    }
                }

                @Override
                public void displayAd() {
                    mAdView.setVisibility(View.VISIBLE);
                }

                @Override
                public void hideAd() {
                    mAdView.setVisibility(View.GONE);
                }

                @Override
                public void submitScore(int score) {
                    if (gameHelper.isSignedIn()) {
                        Games.Leaderboards.submitScore(gameHelper.getApiClient(),
                                getString(R.string.leaderboard_high_scores), score);
                    } else {
                        GameManager.getInstance().saveScore(score);
                    }
                }

                @Override
                public void displayLeaderboard() {
                    if (gameHelper.isSignedIn()) {
                        startActivityForResult(Games.Leaderboards.getLeaderboardIntent(gameHelper.getApiClient(),
                                getString(R.string.leaderboard_high_scores)), 24);
                    } else {
                        gameHelper.beginUserInitiatedSignIn();
                        mLeaderboardRequested = true;
                    }
                }

                @Override
                public void displayAchievements() {
                    if (gameHelper.isSignedIn()) {
                        startActivityForResult(
                                Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 25);
                    } else {
                        gameHelper.beginUserInitiatedSignIn();
                        mAchievementsRequested = true;
                    }
                }

                @Override
                public void share() {
                    String url = String.format(" ",
                            BuildConfig.APPLICATION_ID);
                    String message = String.format(Constants.SHARE_MESSAGE_PREFIX, url);
                    Intent share = new Intent(Intent.ACTION_SEND);
                    share.setType("text/plain");
                    share.putExtra(Intent.EXTRA_TEXT, message);
                    startActivity(Intent.createChooser(share, Constants.SHARE_TITLE));
                }

                @Override
                public void unlockAchievement(String id) {
                    if (gameHelper.isSignedIn()) {
                        Games.Achievements.unlock(gameHelper.getApiClient(), id);
                        GameManager.getInstance().setAchievementUnlocked(id);
                    }
                }

                @Override
                public void incrementAchievement(String id, int steps) {
                    if (gameHelper.isSignedIn()) {
                        Games.Achievements.increment(gameHelper.getApiClient(), id, steps);
                        GameManager.getInstance().incrementAchievementCount(id, steps);
                    }
                }

                @Override
                public String getGettingStartedAchievementId() {
                    return getString(R.string.achievement_getting_started);
                }

                @Override
                public String getLikeARoverAchievementId() {
                    return getString(R.string.achievement_like_a_rover);
                }

                @Override
                public String getSpiritAchievementId() {
                    return getString(R.string.achievement_spirit);
                }

                @Override
                public String getCuriosityAchievementId() {
                    return getString(R.string.achievement_curiosity);
                }

                @Override
                public String get5kClubAchievementId() {
                    return getString(R.string.achievement_5k_club);
                }

                @Override
                public String get10kClubAchievementId() {
                    return getString(R.string.achievement_10k_club);
                }

                @Override
                public String get25kClubAchievementId() {
                    return getString(R.string.achievement_25k_club);
                }

                @Override
                public String get50kClubAchievementId() {
                    return getString(R.string.achievement_50k_club);
                }

                @Override
                public String get10JumpStreetAchievementId() {
                    return getString(R.string.achievement_10_jump_street);
                }

                @Override
                public String get100JumpStreetAchievementId() {
                    return getString(R.string.achievement_100_jump_street);
                }

                @Override
                public String get500JumpStreetAchievementId() {
                    return getString(R.string.achievement_500_jump_street);
                }

                private String getAdMobUnitId() {

                    return getString(R.string.ad_unit_id); // Declare the banner ad unit id its in string.xml
                }

            }
</code>```

答:
By createAdView() method you're not loading ad on adView only you're calling loadAd() method on mInterstitialAd , that may be one of the reason that you not getting banner Ad. Also you should call addTestDevice(AdRequest.DEVICE_ID_EMULATOR) on Request Builder, if your App is in testing mode.

Loading InterstitialAd is not enough, after loading you need to call show() method on InterstitialAd.

I've already answered, how you should integrate AdMob in LibGDX :

Banner Ad Integration : Adding Admob to libgdx

Interstitial Ad Integration  : How can I implement AdMob Ads in a LibGDX Android project?

Body:
This one was the original code without comments

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.gamestudio24.martianrun.MartianRun;
import com.gamestudio24.martianrun.utils.Constants;
import com.gamestudio24.martianrun.utils.GameEventListener;
import com.gamestudio24.martianrun.utils.GameManager;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.games.Games;
import com.google.games.basegameutils.GameHelper;

public class AndroidLauncher extends AndroidApplication implements GameHelper.GameHelperListener,
        GameEventListener {

    private static String SAVED_LEADERBOARD_REQUESTED = "SAVED_LEADERBOARD_REQUESTED";
    private static String SAVED_ACHIEVEMENTS_REQUESTED = "SAVED_ACHIEVEMENTS_REQUESTED";

    private GameHelper gameHelper;

    private AdView mAdView;
    private boolean mLeaderboardRequested;
    private boolean mAchievementsRequested;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create the layout
        RelativeLayout layout = new RelativeLayout(this);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

        // Game view
        View gameView = initializeForView(new MartianRun(this), config);
        layout.addView(gameView);

        mAdView = createAdView();
        mAdView.loadAd(createAdRequest());

        layout.addView(mAdView, getAdParams());

        setContentView(layout);

        gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
        gameHelper.setup(this);
        gameHelper.setMaxAutoSignInAttempts(0);
    }

    @Override
    protected void onStart() {
        super.onStart();
        gameHelper.onStart(this);
        GoogleAnalytics.getInstance(this).reportActivityStart(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        gameHelper.onStop();
        GoogleAnalytics.getInstance(this).reportActivityStop(this);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        gameHelper.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putBoolean(SAVED_LEADERBOARD_REQUESTED, mLeaderboardRequested);
        outState.putBoolean(SAVED_ACHIEVEMENTS_REQUESTED, mAchievementsRequested);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        mLeaderboardRequested = savedInstanceState.getBoolean(SAVED_LEADERBOARD_REQUESTED, false);
        mAchievementsRequested = savedInstanceState.getBoolean(SAVED_ACHIEVEMENTS_REQUESTED, false);
    }

    private AdRequest createAdRequest() {
        return new AdRequest.Builder()
                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice("461B8D3A7843CE98FD0EBD0917030589")
                .build();

    }

    private AdView createAdView() {
        AdView adView = new AdView(this);

        adView.setAdSize(AdSize.SMART_BANNER);
        adView.setAdUnitId(getAdMobUnitId());

        return adView;
    }

    private RelativeLayout.LayoutParams getAdParams() {
        RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.MATCH_PARENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);

        adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

        return adParams;
    }

    @Override
    public void onSignInFailed() {
        // handle sign-in failure (e.g. show Sign In button)
        mLeaderboardRequested = false;
        mAchievementsRequested = false;
    }

    @Override
    public void onSignInSucceeded() {
        // handle sign-in success
        if (GameManager.getInstance().hasSavedMaxScore()) {
            GameManager.getInstance().submitSavedMaxScore();
        }

        if (mLeaderboardRequested) {
            displayLeaderboard();
            mLeaderboardRequested = false;
        }

        if (mAchievementsRequested) {
            displayAchievements();
            mAchievementsRequested = false;
        }
    }

    @Override
    public void displayAd() {
        mAdView.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideAd() {
        mAdView.setVisibility(View.GONE);
    }

    @Override
    public void submitScore(int score) {
        if (gameHelper.isSignedIn()) {
            Games.Leaderboards.submitScore(gameHelper.getApiClient(),
                    getString(R.string.leaderboard_high_scores), score);
        } else {
            GameManager.getInstance().saveScore(score);
        }
    }

    @Override
    public void displayLeaderboard() {
        if (gameHelper.isSignedIn()) {
            startActivityForResult(Games.Leaderboards.getLeaderboardIntent(gameHelper.getApiClient(),
                    getString(R.string.leaderboard_high_scores)), 24);
        } else {
            gameHelper.beginUserInitiatedSignIn();
            mLeaderboardRequested = true;
        }
    }

    @Override
    public void displayAchievements() {
        if (gameHelper.isSignedIn()) {
            startActivityForResult(
                    Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 25);
        } else {
            gameHelper.beginUserInitiatedSignIn();
            mAchievementsRequested = true;
        }
    }

    @Override
    public void share() {
        String url = String.format(" ",
                BuildConfig.APPLICATION_ID);
        String message = String.format(Constants.SHARE_MESSAGE_PREFIX, url);
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("text/plain");
        share.putExtra(Intent.EXTRA_TEXT, message);
        startActivity(Intent.createChooser(share, Constants.SHARE_TITLE));
    }

    @Override
    public void unlockAchievement(String id) {
        if (gameHelper.isSignedIn()) {
            Games.Achievements.unlock(gameHelper.getApiClient(), id);
            GameManager.getInstance().setAchievementUnlocked(id);
        }
    }

    @Override
    public void incrementAchievement(String id, int steps) {
        if (gameHelper.isSignedIn()) {
            Games.Achievements.increment(gameHelper.getApiClient(), id, steps);
            GameManager.getInstance().incrementAchievementCount(id, steps);
        }
    }

    @Override
    public String getGettingStartedAchievementId() {
        return getString(R.string.achievement_getting_started);
    }

    @Override
    public String getLikeARoverAchievementId() {
        return getString(R.string.achievement_like_a_rover);
    }

    @Override
    public String getSpiritAchievementId() {
        return getString(R.string.achievement_spirit);
    }

    @Override
    public String getCuriosityAchievementId() {
        return getString(R.string.achievement_curiosity);
    }

    @Override
    public String get5kClubAchievementId() {
        return getString(R.string.achievement_5k_club);
    }

    @Override
    public String get10kClubAchievementId() {
        return getString(R.string.achievement_10k_club);
    }

    @Override
    public String get25kClubAchievementId() {
        return getString(R.string.achievement_25k_club);
    }

    @Override
    public String get50kClubAchievementId() {
        return getString(R.string.achievement_50k_club);
    }

    @Override
    public String get10JumpStreetAchievementId() {
        return getString(R.string.achievement_10_jump_street);
    }

    @Override
    public String get100JumpStreetAchievementId() {
        return getString(R.string.achievement_100_jump_street);
    }

    @Override
    public String get500JumpStreetAchievementId() {
        return getString(R.string.achievement_500_jump_street);
    }

    private String getAdMobUnitId() {
        return getString(R.string.ad_unit_id);
    }

This errors occurs when to generate the ads on libgdx game

07-04 11:57:44.181 8773-8773/com.gamestudio24.cityescape.android D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
    07-04 11:57:44.301 8773-8773/com.gamestudio24.cityescape.android I/Ads: Starting ad request.
    07-04 11:57:44.301 8773-8773/com.gamestudio24.cityescape.android I/Ads: Use AdRequest.Builder.addTestDevice("461B8D3A7843CE98FD0EBD0917030589") to get test ads on this device.
    07-04 11:57:47.971 8773-8773/com.gamestudio24.cityescape.android I/Ads: Ad finished loading.

            import android.content.Intent;
            import android.os.Bundle;
            import android.view.View;
            import android.view.Window;
            import android.view.WindowManager;
            import android.widget.RelativeLayout;
            import com.badlogic.gdx.backends.android.AndroidApplication;
            import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
            import com.gamestudio24.martianrun.MartianRun;
            import com.gamestudio24.martianrun.utils.Constants;
            import com.gamestudio24.martianrun.utils.GameEventListener;
            import com.gamestudio24.martianrun.utils.GameManager;
            import com.google.android.gms.ads.AdListener;
            import com.google.android.gms.ads.AdRequest;
            import com.google.android.gms.ads.AdSize;
            import com.google.android.gms.ads.AdView;
            import com.google.android.gms.ads.InterstitialAd;
            import com.google.android.gms.ads.MobileAds;
            import com.google.android.gms.analytics.GoogleAnalytics;
            import com.google.android.gms.games.Games;
            import com.google.games.basegameutils.GameHelper;

            public class AndroidLauncher extends AndroidApplication implements GameHelper.GameHelperListener,
                    GameEventListener {

                private static String SAVED_LEADERBOARD_REQUESTED = "SAVED_LEADERBOARD_REQUESTED";
                private static String SAVED_ACHIEVEMENTS_REQUESTED = "SAVED_ACHIEVEMENTS_REQUESTED";

                private GameHelper gameHelper;
                private InterstitialAd mInterstitialAd;

                private AdView mAdView;
                private boolean mLeaderboardRequested;
                private boolean mAchievementsRequested;

                @Override
                protected void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);

                    // Create the layout
                    RelativeLayout layout = new RelativeLayout(this);
                    MobileAds.initialize(this,"ca-app-pub-3940256099942544/1033173712");

                    requestWindowFeature(Window.FEATURE_NO_TITLE);
                    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
                    getWindow().clearFlags(
                            WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

                    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

                    // Game view
                    View gameView = initializeForView(new MartianRun(this), config);
                    layout.addView(gameView);

                    mAdView = createAdView();
                   // mAdView.loadAd(createAdRequest());

                    layout.addView(mAdView, getAdParams());

                    setContentView(layout);

                    gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
                    gameHelper.setup(this);
                    gameHelper.setMaxAutoSignInAttempts(0);
                }

                @Override
                protected void onStart() {
                    super.onStart();
                    gameHelper.onStart(this);
                    GoogleAnalytics.getInstance(this).reportActivityStart(this);
                }

                @Override
                protected void onStop() {
                    super.onStop();
                    gameHelper.onStop();
                    GoogleAnalytics.getInstance(this).reportActivityStop(this);
                }

                @Override
                protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                    super.onActivityResult(requestCode, resultCode, data);
                    gameHelper.onActivityResult(requestCode, resultCode, data);
                }

                @Override
                protected void onSaveInstanceState(Bundle outState) {
                    super.onSaveInstanceState(outState);
                    outState.putBoolean(SAVED_LEADERBOARD_REQUESTED, mLeaderboardRequested);
                    outState.putBoolean(SAVED_ACHIEVEMENTS_REQUESTED, mAchievementsRequested);
                }

                @Override
                protected void onRestoreInstanceState(Bundle savedInstanceState) {
                    super.onRestoreInstanceState(savedInstanceState);
                    mLeaderboardRequested = savedInstanceState.getBoolean(SAVED_LEADERBOARD_REQUESTED, false);
                    mAchievementsRequested = savedInstanceState.getBoolean(SAVED_ACHIEVEMENTS_REQUESTED, false);
                }

            //        AdRequest adRequest = new AdRequest.Builder()
            //                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            //                .build();

        // I want to show here banner and interstitial ads but its not show what to do for that because i declare banner ad unit id in string.xml and interestitial ad unit id in this android launcher
                private AdView createAdView() {
                    AdView adView = new AdView(this);
                    adView.setAdSize(AdSize.SMART_BANNER);
                    adView.setAdUnitId(getAdMobUnitId());
                    mInterstitialAd = new InterstitialAd(this);
                    mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
                    mInterstitialAd.loadAd(new AdRequest.Builder().build());
                    mInterstitialAd.setAdListener(new AdListener() {
                        @Override
                        public void onAdClosed() {
                            super.onAdClosed();
                        }
                    });

                    return adView;
                }

                private RelativeLayout.LayoutParams getAdParams() {
                    AdRequest.Builder builder = new AdRequest.Builder();
                    builder.addTestDevice(" ");
                    RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(
                            RelativeLayout.LayoutParams.MATCH_PARENT,
                            RelativeLayout.LayoutParams.WRAP_CONTENT);

                    adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

                    return adParams;
                }

                @Override
                public void onSignInFailed() {
                    // handle sign-in failure (e.g. show Sign In button)
                    mLeaderboardRequested = false;
                    mAchievementsRequested = false;
                }

                @Override
                public void onSignInSucceeded() {
                    // handle sign-in success
                    if (GameManager.getInstance().hasSavedMaxScore()) {
                        GameManager.getInstance().submitSavedMaxScore();
                    }

                    if (mLeaderboardRequested) {
                        displayLeaderboard();
                        mLeaderboardRequested = false;
                    }

                    if (mAchievementsRequested) {
                        displayAchievements();
                        mAchievementsRequested = false;
                    }
                }

                @Override
                public void displayAd() {
                    mAdView.setVisibility(View.VISIBLE);
                }

                @Override
                public void hideAd() {
                    mAdView.setVisibility(View.GONE);
                }

                @Override
                public void submitScore(int score) {
                    if (gameHelper.isSignedIn()) {
                        Games.Leaderboards.submitScore(gameHelper.getApiClient(),
                                getString(R.string.leaderboard_high_scores), score);
                    } else {
                        GameManager.getInstance().saveScore(score);
                    }
                }

                @Override
                public void displayLeaderboard() {
                    if (gameHelper.isSignedIn()) {
                        startActivityForResult(Games.Leaderboards.getLeaderboardIntent(gameHelper.getApiClient(),
                                getString(R.string.leaderboard_high_scores)), 24);
                    } else {
                        gameHelper.beginUserInitiatedSignIn();
                        mLeaderboardRequested = true;
                    }
                }

                @Override
                public void displayAchievements() {
                    if (gameHelper.isSignedIn()) {
                        startActivityForResult(
                                Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 25);
                    } else {
                        gameHelper.beginUserInitiatedSignIn();
                        mAchievementsRequested = true;
                    }
                }

                @Override
                public void share() {
                    String url = String.format(" ",
                            BuildConfig.APPLICATION_ID);
                    String message = String.format(Constants.SHARE_MESSAGE_PREFIX, url);
                    Intent share = new Intent(Intent.ACTION_SEND);
                    share.setType("text/plain");
                    share.putExtra(Intent.EXTRA_TEXT, message);
                    startActivity(Intent.createChooser(share, Constants.SHARE_TITLE));
                }

                @Override
                public void unlockAchievement(String id) {
                    if (gameHelper.isSignedIn()) {
                        Games.Achievements.unlock(gameHelper.getApiClient(), id);
                        GameManager.getInstance().setAchievementUnlocked(id);
                    }
                }

                @Override
                public void incrementAchievement(String id, int steps) {
                    if (gameHelper.isSignedIn()) {
                        Games.Achievements.increment(gameHelper.getApiClient(), id, steps);
                        GameManager.getInstance().incrementAchievementCount(id, steps);
                    }
                }

                @Override
                public String getGettingStartedAchievementId() {
                    return getString(R.string.achievement_getting_started);
                }

                @Override
                public String getLikeARoverAchievementId() {
                    return getString(R.string.achievement_like_a_rover);
                }

                @Override
                public String getSpiritAchievementId() {
                    return getString(R.string.achievement_spirit);
                }

                @Override
                public String getCuriosityAchievementId() {
                    return getString(R.string.achievement_curiosity);
                }

                @Override
                public String get5kClubAchievementId() {
                    return getString(R.string.achievement_5k_club);
                }

                @Override
                public String get10kClubAchievementId() {
                    return getString(R.string.achievement_10k_club);
                }

                @Override
                public String get25kClubAchievementId() {
                    return getString(R.string.achievement_25k_club);
                }

                @Override
                public String get50kClubAchievementId() {
                    return getString(R.string.achievement_50k_club);
                }

                @Override
                public String get10JumpStreetAchievementId() {
                    return getString(R.string.achievement_10_jump_street);
                }

                @Override
                public String get100JumpStreetAchievementId() {
                    return getString(R.string.achievement_100_jump_street);
                }

                @Override
                public String get500JumpStreetAchievementId() {
                    return getString(R.string.achievement_500_jump_street);
                }

                private String getAdMobUnitId() {

                    return getString(R.string.ad_unit_id); // Declare the banner ad unit id its in string.xml
                }

            }


来源: stackexchange

问:
How to arrange JSON value in angularjs?
Hi need help on how to loop this array value into 3 column using angularjs.

Currently my view is like this
Html table contain 3 column the value showing in vertical instead of horizontal
Below is my JSON view

{
  "Table1": {
  "titleList": [
      "Table1",
      "Start Date",
      "Completion Date"
    ]
    "dataList": [
      {
        "Name": "Ayu",
        "startDate": "30 Jul 2015",
        "completionDate": "30 Jul 2015"
      }
    ],
  },
  "Table2": {
  "titleList": [
      "Table2",
      "Start Date",
      "Completion Date"
    ]
    "dataList": [
      {
        "Name": "Siti",
        "startDate": "",
        "completionDate": ""
      },
      {
        "Name": "wan",
        "startDate": "",
        "completionDate": ""
      },
      {
        "Name": "nita",
        "startDate": "",
        "completionDate": ""
      },
    ],
  },
  "Table3": {
  "titleList": [
      "HGA",
      "Start Date",
      "Completion Date"
    ]
    "dataList": [
      {
        "Name": "Fatimah",
        "startDate": "",
        "completionDate": ""
      },
      {
        "Name": "Nora",
        "startDate": "",
        "completionDate": ""
      },
    ],

  }
}```
</div>
</div>
</p>

<p>My angularjs showing as below
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><tbody ng-repeat ="(nodeSummaryKey, nodeSummaryVal) in nodeSummary">

      <tr ng-if="isObject(nodeSummaryVal)" ng-class-odd="'odd'" ng-class-even="'even'" ng-repeat = "(dataKey, dataValue) in nodeSummaryVal" >
       <td ng-if="dataKey == 'titleList'" class="stx-attributes-group"
       ng-repeat="(eachDataKey, eachDataValue) in nodeSummaryVal.titleList">{{eachDataValue}}</td>

       <td ng-if="dataKey == 'dataList'" ng-repeat="(eachDataKey, eachDataValue) in dataValue">
        <div ng-repeat="(eachKey, eachValue) in eachDataValue">{{eachValue}}</div>

      </tr>
     </tbody></code>```

答:
You could achieve it by simple ng-repeat:

angular.module('app', []).controller('Controller', function($scope) {
  $scope.table_data = {
    "Table1": {
      "titleList": ["Table1", "Start Date", "Completion Date"],
      "dataList": [{
        "Name": "Ayu",
        "startDate": "30 Jul 2015",
        "completionDate": "30 Jul 2015"
      }],
    },
    "Table2": {
      "titleList": ["Table2", "Start Date", "Completion Date"],
      "dataList": [{
        "Name": "Siti",
        "startDate": "",
        "completionDate": ""
      }, {
        "Name": "wan",
        "startDate": "",
        "completionDate": ""
      }, {
        "Name": "nita",
        "startDate": "",
        "completionDate": ""
      }, ],
    },
    "Table3": {
      "titleList": ["HGA", "Start Date", "Completion Date"],
      "dataList": [{
        "Name": "Fatimah",
        "startDate": "",
        "completionDate": ""
      }, {
        "Name": "Nora",
        "startDate": "",
        "completionDate": ""
      }, ],
    }
  };

});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}</code>```

<!DOCTYPE html>

{{dta_key}}

            {{thead}}

            {{trow}}

```

ContentLicense: CC BY-SA 3.0

Title: How to arrange JSON value in angularjs?

Body:
Hi need help on how to loop this array value into 3 column using angularjs.

Currently my view is like this
Html table contain 3 column the value showing in vertical instead of horizontal
Below is my JSON view

{
  "Table1": {
  "titleList": [
      "Table1",
      "Start Date",
      "Completion Date"
    ]
    "dataList": [
      {
        "Name": "Ayu",
        "startDate": "30 Jul 2015",
        "completionDate": "30 Jul 2015"
      }
    ],
  },
  "Table2": {
  "titleList": [
      "Table2",
      "Start Date",
      "Completion Date"
    ]
    "dataList": [
      {
        "Name": "Siti",
        "startDate": "",
        "completionDate": ""
      },
      {
        "Name": "wan",
        "startDate": "",
        "completionDate": ""
      },
      {
        "Name": "nita",
        "startDate": "",
        "completionDate": ""
      },
    ],
  },
  "Table3": {
  "titleList": [
      "HGA",
      "Start Date",
      "Completion Date"
    ]
    "dataList": [
      {
        "Name": "Fatimah",
        "startDate": "",
        "completionDate": ""
      },
      {
        "Name": "Nora",
        "startDate": "",
        "completionDate": ""
      },
    ],

  }
}

My angularjs showing as below

       {{eachDataValue}}

{{eachValue}}

Body:
You could achieve it by simple ng-repeat:

angular.module('app', []).controller('Controller', function($scope) {
  $scope.table_data = {
    "Table1": {
      "titleList": ["Table1", "Start Date", "Completion Date"],
      "dataList": [{
        "Name": "Ayu",
        "startDate": "30 Jul 2015",
        "completionDate": "30 Jul 2015"
      }],
    },
    "Table2": {
      "titleList": ["Table2", "Start Date", "Completion Date"],
      "dataList": [{
        "Name": "Siti",
        "startDate": "",
        "completionDate": ""
      }, {
        "Name": "wan",
        "startDate": "",
        "completionDate": ""
      }, {
        "Name": "nita",
        "startDate": "",
        "completionDate": ""
      }, ],
    },
    "Table3": {
      "titleList": ["HGA", "Start Date", "Completion Date"],
      "dataList": [{
        "Name": "Fatimah",
        "startDate": "",
        "completionDate": ""
      }, {
        "Name": "Nora",
        "startDate": "",
        "completionDate": ""
      }, ],
    }
  };

});

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

<!DOCTYPE html>

<head>
  <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script>
  <script src="script.js"></script>
</head>

<body ng-app="app">
  <div ng-controller="Controller">
    <div ng-repeat="(dta_key,dta_value) in table_data">
      <h1>{{dta_key}}</h1>
      <table >
        <thead>
          <tr>
            <th ng-repeat="thead in dta_value.titleList">{{thead}}</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="tbody in dta_value.dataList">
            <td ng-repeat="trow in tbody">{{trow}}</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</body>

</html>


问:
value in ng-options is stored in ng-model as object instead of string
I have a "format" object which contains a list of "datamapping" objects. My datamapping object contains these fields (but we're only concerned with concatenation):

dataMapping.column = null;
dataMapping.datatype = null;
dataMapping.dataMapping = null;
dataMapping.mappingName = "Mapping " + (format.datamappings.length+1);
dataMapping.hasConcatenation = true;
dataMapping.concatenation = ["", ""];```
</div>
</div>
</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div style="margin: 1px 0px" ng-repeat="mapping in format.datamappings track by $index"> <!-- using a class for css is not working (even if it has !important), dont know why-->
    <hr width="50" align="left">
    {{mapping.mappingName}}
    <div style="margin-left: 13px"> <!-- using a class for css is not working (even if it has !important), dont know why-->
     Column
     <input class="form-control inline width-small" ng-class="{'unfilled': mapping.column == '' || mapping.column == null}" onkeypress="return ((event.charCode >= 65 && event.charCode <= 90) || event.charCode == 8)" type="text" ng-model="mapping.column"/>
     Datatype
     <select class="form-control inline width-medium1" ng-class="{'unfilled': mapping.datatype == '' || mapping.datatype == null}" ng-model="mapping.datatype">
      <option value="text">text</option>
      <option value="number">number</option>
      <option value="decimal">decimal</option>
     </select>
     Data mapping
     <select class="form-control inline width-medium1" ng-class="{'unfilled': mapping.dataMapping == '' || mapping.dataMapping == null}" ng-model="mapping.dataMapping">
      <option value="manuf">Manufacturer</option>
      <option value="product_name">Product Name</option>
      <option value="unit">Unit / Quantity</option>
      <option value="price">Price</option>
     </select>
     <button class="btn btn-danger" ng-click="deleteMapping(format, $index)">Delete mapping</button>
     <input type="checkbox" ng-model="mapping.hasConcatenation" ng-click="includeConcatenation(mapping)"> Has Concatenation</label>

                                        <!-- LOOK HERE -->
     <div ng-if="mapping.hasConcatenation">
      Concatenation
      <select ng-repeat="concat in mapping.concatenation track by $index" class="form-control inline width-medium1" ng-options="x.mappingName for x in format.datamappings" ng-model="mapping.concatenation[$index]"></select>
                          </div>
 </div>
</div></code>```

Let's say we have 2 mappings in the dropdown list: "Mapping 1" and "Mapping 2". When I select a value from the dropdown, instead of a string being stored in the concatenation array (mapping.concatenation[$index]), it stores an object instead as shown in the image below. And if you expand the object you will see that it apparently references itself infinitely.

答:
Can you try once with below code, because you are displaying mappingName and selecting entire object , if you want to select only name try as below

ng-options="x.mappingName as x.mappingName for x in format.datamappings"

Reference https://docs.angularjs.org/api/ng/directive/ngOptions

Using select as will bind the result of the select expression to the
  model, but the value of the  and  html elements will
  be either the index (for array data sources) or property name (for
  object data sources) of the value within the collection. If a track by
  expression is used, the result of that expression will be set as the
  value of the option and select elements.

Body:
I have a "format" object which contains a list of "datamapping" objects. My datamapping object contains these fields (but we're only concerned with concatenation):

dataMapping.column = null;
dataMapping.datatype = null;
dataMapping.dataMapping = null;
dataMapping.mappingName = "Mapping " + (format.datamappings.length+1);
dataMapping.hasConcatenation = true;
dataMapping.concatenation = ["", ""];

    {{mapping.mappingName}}

     Column
     <input class="form-control inline width-small" ng-class="{'unfilled': mapping.column == '' || mapping.column == null}" onkeypress="return ((event.charCode >= 65 && event.charCode <= 90) || event.charCode == 8)" type="text" ng-model="mapping.column"/>
     Datatype
     <select class="form-control inline width-medium1" ng-class="{'unfilled': mapping.datatype == '' || mapping.datatype == null}" ng-model="mapping.datatype">
      <option value="text">text</option>
      <option value="number">number</option>
      <option value="decimal">decimal</option>
     </select>
     Data mapping
     <select class="form-control inline width-medium1" ng-class="{'unfilled': mapping.dataMapping == '' || mapping.dataMapping == null}" ng-model="mapping.dataMapping">
      <option value="manuf">Manufacturer</option>
      <option value="product_name">Product Name</option>
      <option value="unit">Unit / Quantity</option>
      <option value="price">Price</option>
     </select>
     <button class="btn btn-danger" ng-click="deleteMapping(format, $index)">Delete mapping</button>
     <input type="checkbox" ng-model="mapping.hasConcatenation" ng-click="includeConcatenation(mapping)"> Has Concatenation

      Concatenation
      <select ng-repeat="concat in mapping.concatenation track by $index" class="form-control inline width-medium1" ng-options="x.mappingName for x in format.datamappings" ng-model="mapping.concatenation[$index]"></select>

Let's say we have 2 mappings in the dropdown list: "Mapping 1" and "Mapping 2". When I select a value from the dropdown, instead of a string being stored in the concatenation array (mapping.concatenation[$index]), it stores an object instead as shown in the image below. And if you expand the object you will see that it apparently references itself infinitely.


问:
Manually telling my ListBox's scrollbar where to be
```<code>private void button2_Click(object sender, EventArgs e)
{
    listBox1.AutoScrollOffset.Y = 10;
}
</code>```

I'm trying to manually set the location of my vertical scrollbar using code during runtime. This is what I've tried.

The .Y property says: "Gets or sets the Y coordinate of this point". Why doesn't this compile and give me an exception:

Error 1   Cannot modify the return value
  of
  'System.Windows.Forms.Control.AutoScrollOffset'
  because it is not a variable

答:
```<code>listBox1.AutoScrollOffset = new Point(listBox1.AutoScrollOffset.X, 10);
</code>```

OwnerDisplayName: delete

ContentLicense: CC BY-SA 2.5

Body:
private void button2_Click(object sender, EventArgs e)
{
    listBox1.AutoScrollOffset.Y = 10;
}

I'm trying to manually set the location of my vertical scrollbar using code during runtime. This is what I've tried.

The .Y property says: "Gets or sets the Y coordinate of this point". Why doesn't this compile and give me an exception:

Error 1   Cannot modify the return value
  of
  'System.Windows.Forms.Control.AutoScrollOffset'
  because it is not a variable


问:
Calling captureOutput in IBAction
I'd like to create an app, which after clicking IBAction button should display current frame from live camera on UIImageView.
Using this method: https://developer.apple.com/library/ios/qa/qa1702/_index.html

I'd like to create fuction in IBAction fuction. This one exactly:

```<code>- (void)captureOutput:(AVCaptureOutput *)captureOutput
</code>```

Unfortunately after dozen of attempts I can't do it.

Summarizing: How to create a function (void), which contains image in
  UIImage form and save it to object in storyboard?

I'd be grateful for any help.
Regards.

答:
Use this method to capture still images from AVCaptureSession  where stillImageOutput is AVCaptureStillImageOutput:

```<code>[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
    CVImageBufferRef imageBuffer =CMSampleBufferGetImageBuffer(imageSampleBuffer);
    CIImage *ciImage = [CIImage imageWithCVPixelBuffer:imageBuffer];
    CIContext *temporaryContext = [CIContext contextWithOptions:nil];
    CGImageRef videoImage =[temporaryContext
        createCGImage:ciImage
        fromRect:CGRectMake(
            0, 0,
            CVPixelBufferGetWidth(imageBuffer),
            CVPixelBufferGetHeight(imageBuffer)
        )];
    UIImage *image = [[UIImage alloc] initWithCGImage:videoImage];
    self.imageView.image = image;
}
</code>```

Title: Calling captureOutput in IBAction

Body:
I'd like to create an app, which after clicking IBAction button should display current frame from live camera on UIImageView.
Using this method: https://developer.apple.com/library/ios/qa/qa1702/_index.html

I'd like to create fuction in IBAction fuction. This one exactly:

- (void)captureOutput:(AVCaptureOutput *)captureOutput

Unfortunately after dozen of attempts I can't do it.

Summarizing: How to create a function (void), which contains image in
  UIImage form and save it to object in storyboard?

I'd be grateful for any help.
Regards.

Body:
Use this method to capture still images from AVCaptureSession  where stillImageOutput is AVCaptureStillImageOutput:

[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error)
{
    CVImageBufferRef imageBuffer =CMSampleBufferGetImageBuffer(imageSampleBuffer);
    CIImage *ciImage = [CIImage imageWithCVPixelBuffer:imageBuffer];
    CIContext *temporaryContext = [CIContext contextWithOptions:nil];
    CGImageRef videoImage =[temporaryContext
        createCGImage:ciImage
        fromRect:CGRectMake(
            0, 0,
            CVPixelBufferGetWidth(imageBuffer),
            CVPixelBufferGetHeight(imageBuffer)
        )];
    UIImage *image = [[UIImage alloc] initWithCGImage:videoImage];
    self.imageView.image = image;
}


问:
asp.net c# how to know how many connection object are currently open but not closed by web page
am working on one project which is web based application many developers are used connection object but they are not closed it.

so i can i get the details by webpage that how many connection object are currently used but not closed

am using some code which is mention here

```<code>protected void btnCheckConnection_Click(object sender, EventArgs e)
        {
            GetIntegratedSecurityConnectionString();
            SetUpPerformanceCounters();
            CreateConnections();
        }

private static string GetIntegratedSecurityConnectionString()
        {
            string @SqlConn = "Server=190.196.19.12;UID=test1;PWD=test1;Database=test";
            return @SqlConn;
        }

private void CreateConnections()
    {
        // List the Performance counters.
        WritePerformanceCounters();

        // Create 4 connections and display counter information.
        SqlConnection connection1 = new SqlConnection(
              GetIntegratedSecurityConnectionString());
        connection1.Open();
        Console.WriteLine("Opened the 1st Connection:");
        WritePerformanceCounters();

        SqlConnection connection2 = new SqlConnection(
              GetSqlConnectionStringDifferent());
        connection2.Open();
        Response.Write("Opened the 2nd Connection:");
        WritePerformanceCounters();

        SqlConnection connection3 = new SqlConnection(
              GetSqlConnectionString());
        connection3.Open();
        Console.WriteLine("Opened the 3rd Connection:");
        WritePerformanceCounters();

        SqlConnection connection4 = new SqlConnection(
              GetSqlConnectionString());
        connection4.Open();
        Console.WriteLine("Opened the 4th Connection:");
        WritePerformanceCounters();

        connection1.Close();
        Console.WriteLine("Closed the 1st Connection:");
        WritePerformanceCounters();

        connection2.Close();
        Console.WriteLine("Closed the 2nd Connection:");
        WritePerformanceCounters();

        connection3.Close();
        Console.WriteLine("Closed the 3rd Connection:");
        WritePerformanceCounters();

        connection4.Close();
        Console.WriteLine("Closed the 4th Connection:");
        WritePerformanceCounters();
    }

private enum ADO_Net_Performance_Counters
        {
            NumberOfActiveConnectionPools,
            NumberOfReclaimedConnections,
            HardConnectsPerSecond,
            HardDisconnectsPerSecond,
            NumberOfActiveConnectionPoolGroups,
            NumberOfInactiveConnectionPoolGroups,
            NumberOfInactiveConnectionPools,
            NumberOfNonPooledConnections,
            NumberOfPooledConnections,
            NumberOfStasisConnections,
            NumberOfFreeConnections
            // The following performance counters are more expensive to track.
            // Enable ConnectionPoolPerformanceCounterDetail in your config file.
            //     SoftConnectsPerSecond
            //     SoftDisconnectsPerSecond
            //     NumberOfActiveConnections

        }

  private void SetUpPerformanceCounters()
        {
            connection.Close();
            this.PerfCounters = new PerformanceCounter[11];
            string instanceName = GetInstanceName();
            testInstanceName = instanceName;
            Type apc = typeof(ADO_Net_Performance_Counters);
            int i = 0;
            foreach (string s in Enum.GetNames(apc))
            {
                this.PerfCounters[i] = new PerformanceCounter();
                this.PerfCounters[i].CategoryName = ".NET Data Provider for SqlServer";
                this.PerfCounters[i].CounterName = s;
                this.PerfCounters[i].InstanceName = instanceName;
                i++;
            }
        }
        [DllImport("kernel32.dll", SetLastError = true)]
        static extern int GetCurrentProcessId();

private string GetInstanceName()
        {
            //This works for Winforms apps.
            /*
            string instanceName =
                System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
                */
            //This works for Web apps.

            //string instanceName = System.Environment.UserDomainName; //System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
            string instanceName = System.Reflection.Assembly.GetCallingAssembly().GetName().Name;

            // Must replace special characters like (, ), #, /, \\
            string instanceName2 =
                AppDomain.CurrentDomain.FriendlyName.ToString().Replace('(', '[')
                .Replace(')', ']').Replace('#', '_').Replace('/', '_').Replace('\\', '_');

            // For ASP.NET applications your instanceName will be your CurrentDomain's
            // FriendlyName. Replace the line above that sets the instanceName with this:
            // instanceName = AppDomain.CurrentDomain.FriendlyName.ToString().Replace('(','[')
            // .Replace(')',']').Replace('#','_').Replace('/','_').Replace('\\','_');

            string pid = GetCurrentProcessId().ToString();
            instanceName = instanceName + "[" + pid + "]";
            Console.WriteLine("Instance Name: {0}", instanceName);
            Console.WriteLine("---------------------------");
            return instanceName;
        }

  private void WritePerformanceCounters()
        {
            foreach (PerformanceCounter p in this.PerfCounters)
            {
                string strName = p.CounterName + " = " + p.NextValue();
            }
        }
</code>```

if amusing p.NextValue() then  facing error that Additional information: Instance 'Dummy_Project[9544]' does not exist in the specified Category.

答:
In a web application, always close the connection as soon as you're done with it. Tell all other developers on your team to do the same.

You need to wrap your calls in using statement (or try...catch if you wish to handle the exceptions), and it will close it and dispose it automatically.

That will not really close the connection. It will just return it to the connections pool, and next time you try to open a new connection (within a short time), you will actually be given a connection from the pool. This will significantly enhance the performance and allow your application to scale up better.

Body:
am working on one project which is web based application many developers are used connection object but they are not closed it.

so i can i get the details by webpage that how many connection object are currently used but not closed

am using some code which is mention here

protected void btnCheckConnection_Click(object sender, EventArgs e)
        {
            GetIntegratedSecurityConnectionString();
            SetUpPerformanceCounters();
            CreateConnections();
        }

private static string GetIntegratedSecurityConnectionString()
        {
            string @SqlConn = "Server=190.196.19.12;UID=test1;PWD=test1;Database=test";
            return @SqlConn;
        }

private void CreateConnections()
    {
        // List the Performance counters.
        WritePerformanceCounters();

        // Create 4 connections and display counter information.
        SqlConnection connection1 = new SqlConnection(
              GetIntegratedSecurityConnectionString());
        connection1.Open();
        Console.WriteLine("Opened the 1st Connection:");
        WritePerformanceCounters();

        SqlConnection connection2 = new SqlConnection(
              GetSqlConnectionStringDifferent());
        connection2.Open();
        Response.Write("Opened the 2nd Connection:");
        WritePerformanceCounters();

        SqlConnection connection3 = new SqlConnection(
              GetSqlConnectionString());
        connection3.Open();
        Console.WriteLine("Opened the 3rd Connection:");
        WritePerformanceCounters();

        SqlConnection connection4 = new SqlConnection(
              GetSqlConnectionString());
        connection4.Open();
        Console.WriteLine("Opened the 4th Connection:");
        WritePerformanceCounters();

        connection1.Close();
        Console.WriteLine("Closed the 1st Connection:");
        WritePerformanceCounters();

        connection2.Close();
        Console.WriteLine("Closed the 2nd Connection:");
        WritePerformanceCounters();

        connection3.Close();
        Console.WriteLine("Closed the 3rd Connection:");
        WritePerformanceCounters();

        connection4.Close();
        Console.WriteLine("Closed the 4th Connection:");
        WritePerformanceCounters();
    }

private enum ADO_Net_Performance_Counters
        {
            NumberOfActiveConnectionPools,
            NumberOfReclaimedConnections,
            HardConnectsPerSecond,
            HardDisconnectsPerSecond,
            NumberOfActiveConnectionPoolGroups,
            NumberOfInactiveConnectionPoolGroups,
            NumberOfInactiveConnectionPools,
            NumberOfNonPooledConnections,
            NumberOfPooledConnections,
            NumberOfStasisConnections,
            NumberOfFreeConnections
            // The following performance counters are more expensive to track.
            // Enable ConnectionPoolPerformanceCounterDetail in your config file.
            //     SoftConnectsPerSecond
            //     SoftDisconnectsPerSecond
            //     NumberOfActiveConnections

        }

  private void SetUpPerformanceCounters()
        {
            connection.Close();
            this.PerfCounters = new PerformanceCounter[11];
            string instanceName = GetInstanceName();
            testInstanceName = instanceName;
            Type apc = typeof(ADO_Net_Performance_Counters);
            int i = 0;
            foreach (string s in Enum.GetNames(apc))
            {
                this.PerfCounters[i] = new PerformanceCounter();
                this.PerfCounters[i].CategoryName = ".NET Data Provider for SqlServer";
                this.PerfCounters[i].CounterName = s;
                this.PerfCounters[i].InstanceName = instanceName;
                i++;
            }
        }
        [DllImport("kernel32.dll", SetLastError = true)]
        static extern int GetCurrentProcessId();

private string GetInstanceName()
        {
            //This works for Winforms apps.
            /*
            string instanceName =
                System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
                */
            //This works for Web apps.

            //string instanceName = System.Environment.UserDomainName; //System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
            string instanceName = System.Reflection.Assembly.GetCallingAssembly().GetName().Name;

            // Must replace special characters like (, ), #, /, \\
            string instanceName2 =
                AppDomain.CurrentDomain.FriendlyName.ToString().Replace('(', '[')
                .Replace(')', ']').Replace('#', '_').Replace('/', '_').Replace('\\', '_');

            // For ASP.NET applications your instanceName will be your CurrentDomain's
            // FriendlyName. Replace the line above that sets the instanceName with this:
            // instanceName = AppDomain.CurrentDomain.FriendlyName.ToString().Replace('(','[')
            // .Replace(')',']').Replace('#','_').Replace('/','_').Replace('\\','_');

            string pid = GetCurrentProcessId().ToString();
            instanceName = instanceName + "[" + pid + "]";
            Console.WriteLine("Instance Name: {0}", instanceName);
            Console.WriteLine("---------------------------");
            return instanceName;
        }

  private void WritePerformanceCounters()
        {
            foreach (PerformanceCounter p in this.PerfCounters)
            {
                string strName = p.CounterName + " = " + p.NextValue();
            }
        }

if amusing p.NextValue() then  facing error that Additional information: Instance 'Dummy_Project[9544]' does not exist in the specified Category.


问:
android - Place imageview next to two textviews under each other

How do i create above layout in android studio ?

答:
```<code>  [<RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="100dp"
                    android:background="@drawable/view"
                    android:gravity="fill_horizontal|center">

                    <ImageView
                        android:id="@+id/dp"
                        android:layout_width="60dp"
                        android:layout_height="60dp"
                        android:layout_marginLeft="15dp"
                        app:srcCompat="@drawable/lea" />

                    <TextView
                        android:id="@+id/s_name"
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_alignParentStart="true"
                        android:layout_alignTop="@+id/imageView"
                        android:layout_marginStart="85dp"
                        android:gravity="fill_vertical"
                        android:text="Mathan"
                        android:textColor="#78038A"
                        android:textSize="18.5dp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/s_code"
                        android:layout_width="wrap_content"
                        android:layout_height="30dp"
                        android:layout_alignStart="@+id/s_name"
                        android:layout_below="@+id/s_name"
                        android:fontFamily="serif"
                        android:gravity="fill_vertical"
                        android:text="4320 - XXXXXXXXXXXXXXXXXXX"
                        android:textColor="#000000"
                        android:textSize="16dp"
                        android:textStyle="bold" />

                </RelativeLayout>][1]

  [1]: https://i.stack.imgur.com/Yzg8V.jpg
</code>```


问:
How to save another new files one by one in different name by using .csv file in C#
I have .csv file that sample of file is like this,

```<code>    Date,Pass,CutMark1,Marks1,CutMark2,Marks2
22/06/2017 13:04:18,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:20,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:35,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:37,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:37,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:38,FALSE,FALSE,TRUE,FALSE,FALSE
22/06/2017 13:04:39,FALSE,FALSE,TRUE,FALSE,FALSE
22/06/2017 13:04:40,FALSE,FALSE,TRUE,TRUE,FALSE
22/06/2017 13:04:41,FALSE,FALSE,TRUE,TRUE,TRUE
22/06/2017 13:04:42,FALSE,FALSE,FALSE,TRUE,TRUE
22/06/2017 13:04:44,FALSE,FALSE,FALSE,TRUE,TRUE
22/06/2017 13:04:45,TRUE,FALSE,FALSE,TRUE,TRUE
22/06/2017 13:04:46,TRUE,FALSE,FALSE,TRUE,TRUE
22/06/2017 13:04:48,TRUE,FALSE,FALSE,FALSE,TRUE
22/06/2017 13:04:49,TRUE,FALSE,FALSE,FALSE,TRUE
22/06/2017 13:04:50,TRUE,FALSE,FALSE,FALSE,TRUE
22/06/2017 13:04:52,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:53,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:54,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:56,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:57,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:58,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:05:00,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:01,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:02,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:04,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:05,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:06,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:08,TRUE,TRUE,TRUE,TRUE,FALSE
</code>```

So now I want to save this file as follows;In here Pass column data flow is like this,FALSE>TRUE>FALSE>TRUE ..this is sample of my .csv file.but there is more raw in original file.In here I want to Separate this original .csv file like following ;

First met False so all of False details And check Marks1=TRUE then save Discharge1_Mark1.csv,and look at Marks2 column and if that column true then save Discharge1_Mark2.csv.

Secondly Pass column meet True then check Marks1=TRUE then save Charge1_Mark1.csv,then if  Marks2=true then save Charge1_Mark2.csv.

NOw again Pass column meet False then want to save file Discharge2_Marks1.csv.
like that I want to save my files.

I want to say in here Accordingly Pass column TRUE,False you want to save file like i mentioned before as which time that TRUE,FALSE meet.1,2,3,...you want to check respective pass column TRUE false with respective Marks1,Marks2 column.
In here I want to save my generated file respective therir columns.

If I save Marks1 then column headers should (Date,Pass,CutMarks1,Marks1 )
If i save Marks2 then column header should (Date,Pass,CutMarks2,Marks2)

Please give how I generate files as I mentioned before in my code.my code is following.

```<code>using System.Globalization;

  public static string dateFormatString = "dd/MM/yyyy HH:mm:ss";

  private void btnSeperateFile_Click(object sender, EventArgs e)
        {
            int discharge_counter = 0;
            int charge_counter = 0;

            if (tbOutputFilePath2 != null)
            {

                List<DrawNew> ObservingData = new List<DrawNew>(); // List to store all available DrawNew objects from the CSV

                // Loops through each lines in the CSV
                foreach (string line in System.IO.File.ReadAllLines(outputFilePath.Text).Skip(1)) // .Skip(1) is for skipping header
                {

                    string[] valuesCsvLine = line.Split(',');
                    DrawNew mngInstance = new DrawNew();

                    mngInstance.Date = DateTime.ParseExact(valuesCsvLine[0], dateFormatString, CultureInfo.InvariantCulture);
                    mngInstance.Pass = (valuesCsvLine[1] == "TRUE" ? true : false);
                    mngInstance.CutMark1 = (valuesCsvLine[2] == "TRUE" ?true: false);
                    mngInstance.Marks1 = (valuesCsvLine[3] == "TRUE" ?true: false);
                    mngInstance.CutMark2 = (valuesCsvLine[4] == "TRUE" ? true : false);
                    mngInstance.Marks2 = (valuesCsvLine[5] == "TRUE" ?true: false);

                    ObserveData.Add(mngInstance);

                    if (mngInstance.Pass==true && mngInstance.Marks1==true)
                    {

                    }
                    if (mngInstance.Pass == false && mngInstance.Marks1 == true)
                    {

                    }
                    if (mngInstance.Pass == true && mngInstance.Marks2 == true)
                    {

                    }
                    if (mngInstance.Pass == false && mngInstance.Marks2 == true )
                    {

                    }
                }
            }
</code>```

This is the class for storing data of .csv file:

```<code>class DrawNew
    {
        public DateTime Date { get; set; } // property to store Date
        public bool Pass { get; set; } // property to store ChargeMode
        public bool CutMark1 { get; set; } // property to store ChargeMode
        public bool Marks1 { get; set; } // property to store ScheduleStep
        public bool CutMark2 { get; set; } // property to store ChargeMode
        public bool Marks2 { get; set; } // property to store ScheduleStep
     }
</code>```

My problem is How I generate these files as I mentioned before.please help to solve my problem.

答:
If I understand your problem properly, I would like to suggest like below:

In your DrawNew, I will add a new field to store the FileName which the record should be exported to which csv file.

```<code>public class DrawNew
{
    public DateTime Date { get; set; } // property to store Date
    public bool Pass { get; set; } // property to store ChargeMode
    public bool CutMark1 { get; set; } // property to store ChargeMode
    public bool Marks1 { get; set; } // property to store ScheduleStep
    public bool CutMark2 { get; set; } // property to store ChargeMode
    public bool Marks2 { get; set; } // property to store ScheduleStep
    public string FileName { get; set; }
}
</code>```

Then, in your for loop, I use some parameter to determine the file name for each record.

```<code>List<DrawNew> ObservingData = new List<DrawNew>(); // List to store all available DrawNew objects from the CSV

        // Loops through each lines in the CSV
        var fileName = "";
        var previousPassValue = true;
        var count = 0;
        foreach (string line in System.IO.File.ReadAllLines(outputFilePath.Text).Skip(1)) // .Skip(1) is for skipping header
        {
            string[] valuesCsvLine = line.Split(',');
            DrawNew mngInstance = new DrawNew();

            mngInstance.Date = DateTime.ParseExact(valuesCsvLine[0], dateFormatString, CultureInfo.InvariantCulture);
            mngInstance.Pass = (valuesCsvLine[1] == "TRUE" ? true : false);
            mngInstance.CutMark1 = (valuesCsvLine[2] == "TRUE" ? true : false);
            mngInstance.Marks1 = (valuesCsvLine[3] == "TRUE" ? true : false);
            mngInstance.CutMark2 = (valuesCsvLine[4] == "TRUE" ? true : false);
            mngInstance.Marks2 = (valuesCsvLine[5] == "TRUE" ? true : false);
            if (count == 0)
            {
                previousPassValue = mngInstance.Pass;
                count++;
            }

            if (previousPassValue != mngInstance.Pass)
            {
                previousPassValue = mngInstance.Pass;
                count++;
            }

            if (mngInstance.Pass == true && mngInstance.Marks1 == true)
            {
                fileName = "Charge" + count + "_Mark1.csv";

            }
            if (mngInstance.Pass == false && mngInstance.Marks1 == true)
            {
                fileName = "DisCharge" + count + "_Mark1.csv";
            }
            if (mngInstance.Pass == true && mngInstance.Marks2 == true)
            {
                fileName = "Charge" + count + "_Mark2.csv";
            }
            if (mngInstance.Pass == false && mngInstance.Marks2 == true)
            {
                fileName = "DisCharge" + count + "_Mark2.csv";
            }

            mngInstance.FileName = fileName;

            ObservingData.Add(mngInstance);
        }
</code>```

I assume your data file is correct. And you will sort ObservingData list by FileName before exporting it to excel.

Hope this helps.

Body:
I have .csv file that sample of file is like this,

    Date,Pass,CutMark1,Marks1,CutMark2,Marks2
22/06/2017 13:04:18,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:20,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:35,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:37,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:37,FALSE,TRUE,TRUE,FALSE,FALSE
22/06/2017 13:04:38,FALSE,FALSE,TRUE,FALSE,FALSE
22/06/2017 13:04:39,FALSE,FALSE,TRUE,FALSE,FALSE
22/06/2017 13:04:40,FALSE,FALSE,TRUE,TRUE,FALSE
22/06/2017 13:04:41,FALSE,FALSE,TRUE,TRUE,TRUE
22/06/2017 13:04:42,FALSE,FALSE,FALSE,TRUE,TRUE
22/06/2017 13:04:44,FALSE,FALSE,FALSE,TRUE,TRUE
22/06/2017 13:04:45,TRUE,FALSE,FALSE,TRUE,TRUE
22/06/2017 13:04:46,TRUE,FALSE,FALSE,TRUE,TRUE
22/06/2017 13:04:48,TRUE,FALSE,FALSE,FALSE,TRUE
22/06/2017 13:04:49,TRUE,FALSE,FALSE,FALSE,TRUE
22/06/2017 13:04:50,TRUE,FALSE,FALSE,FALSE,TRUE
22/06/2017 13:04:52,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:53,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:54,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:56,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:57,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:04:58,FALSE,TRUE,TRUE,FALSE,TRUE
22/06/2017 13:05:00,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:01,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:02,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:04,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:05,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:06,TRUE,TRUE,TRUE,TRUE,FALSE
22/06/2017 13:05:08,TRUE,TRUE,TRUE,TRUE,FALSE

So now I want to save this file as follows;In here Pass column data flow is like this,FALSE>TRUE>FALSE>TRUE ..this is sample of my .csv file.but there is more raw in original file.In here I want to Separate this original .csv file like following ;

First met False so all of False details And check Marks1=TRUE then save Discharge1_Mark1.csv,and look at Marks2 column and if that column true then save Discharge1_Mark2.csv.

Secondly Pass column meet True then check Marks1=TRUE then save Charge1_Mark1.csv,then if  Marks2=true then save Charge1_Mark2.csv.

NOw again Pass column meet False then want to save file Discharge2_Marks1.csv.
like that I want to save my files.

I want to say in here Accordingly Pass column TRUE,False you want to save file like i mentioned before as which time that TRUE,FALSE meet.1,2,3,...you want to check respective pass column TRUE false with respective Marks1,Marks2 column.
In here I want to save my generated file respective therir columns.

If I save Marks1 then column headers should (Date,Pass,CutMarks1,Marks1 )
If i save Marks2 then column header should (Date,Pass,CutMarks2,Marks2)

Please give how I generate files as I mentioned before in my code.my code is following.

using System.Globalization;

  public static string dateFormatString = "dd/MM/yyyy HH:mm:ss";

  private void btnSeperateFile_Click(object sender, EventArgs e)
        {
            int discharge_counter = 0;
            int charge_counter = 0;

            if (tbOutputFilePath2 != null)
            {

                List<DrawNew> ObservingData = new List<DrawNew>(); // List to store all available DrawNew objects from the CSV

                // Loops through each lines in the CSV
                foreach (string line in System.IO.File.ReadAllLines(outputFilePath.Text).Skip(1)) // .Skip(1) is for skipping header
                {

                    string[] valuesCsvLine = line.Split(',');
                    DrawNew mngInstance = new DrawNew();

                    mngInstance.Date = DateTime.ParseExact(valuesCsvLine[0], dateFormatString, CultureInfo.InvariantCulture);
                    mngInstance.Pass = (valuesCsvLine[1] == "TRUE" ? true : false);
                    mngInstance.CutMark1 = (valuesCsvLine[2] == "TRUE" ?true: false);
                    mngInstance.Marks1 = (valuesCsvLine[3] == "TRUE" ?true: false);
                    mngInstance.CutMark2 = (valuesCsvLine[4] == "TRUE" ? true : false);
                    mngInstance.Marks2 = (valuesCsvLine[5] == "TRUE" ?true: false);

                    ObserveData.Add(mngInstance);

                    if (mngInstance.Pass==true && mngInstance.Marks1==true)
                    {

                    }
                    if (mngInstance.Pass == false && mngInstance.Marks1 == true)
                    {

                    }
                    if (mngInstance.Pass == true && mngInstance.Marks2 == true)
                    {

                    }
                    if (mngInstance.Pass == false && mngInstance.Marks2 == true )
                    {

                    }
                }
            }

This is the class for storing data of .csv file:

class DrawNew
    {
        public DateTime Date { get; set; } // property to store Date
        public bool Pass { get; set; } // property to store ChargeMode
        public bool CutMark1 { get; set; } // property to store ChargeMode
        public bool Marks1 { get; set; } // property to store ScheduleStep
        public bool CutMark2 { get; set; } // property to store ChargeMode
        public bool Marks2 { get; set; } // property to store ScheduleStep
     }

My problem is How I generate these files as I mentioned before.please help to solve my problem.

Body:
If I understand your problem properly, I would like to suggest like below:

In your DrawNew, I will add a new field to store the FileName which the record should be exported to which csv file.

public class DrawNew
{
    public DateTime Date { get; set; } // property to store Date
    public bool Pass { get; set; } // property to store ChargeMode
    public bool CutMark1 { get; set; } // property to store ChargeMode
    public bool Marks1 { get; set; } // property to store ScheduleStep
    public bool CutMark2 { get; set; } // property to store ChargeMode
    public bool Marks2 { get; set; } // property to store ScheduleStep
    public string FileName { get; set; }
}

Then, in your for loop, I use some parameter to determine the file name for each record.

List<DrawNew> ObservingData = new List<DrawNew>(); // List to store all available DrawNew objects from the CSV

        // Loops through each lines in the CSV
        var fileName = "";
        var previousPassValue = true;
        var count = 0;
        foreach (string line in System.IO.File.ReadAllLines(outputFilePath.Text).Skip(1)) // .Skip(1) is for skipping header
        {
            string[] valuesCsvLine = line.Split(',');
            DrawNew mngInstance = new DrawNew();

            mngInstance.Date = DateTime.ParseExact(valuesCsvLine[0], dateFormatString, CultureInfo.InvariantCulture);
            mngInstance.Pass = (valuesCsvLine[1] == "TRUE" ? true : false);
            mngInstance.CutMark1 = (valuesCsvLine[2] == "TRUE" ? true : false);
            mngInstance.Marks1 = (valuesCsvLine[3] == "TRUE" ? true : false);
            mngInstance.CutMark2 = (valuesCsvLine[4] == "TRUE" ? true : false);
            mngInstance.Marks2 = (valuesCsvLine[5] == "TRUE" ? true : false);
            if (count == 0)
            {
                previousPassValue = mngInstance.Pass;
                count++;
            }

            if (previousPassValue != mngInstance.Pass)
            {
                previousPassValue = mngInstance.Pass;
                count++;
            }

            if (mngInstance.Pass == true && mngInstance.Marks1 == true)
            {
                fileName = "Charge" + count + "_Mark1.csv";

            }
            if (mngInstance.Pass == false && mngInstance.Marks1 == true)
            {
                fileName = "DisCharge" + count + "_Mark1.csv";
            }
            if (mngInstance.Pass == true && mngInstance.Marks2 == true)
            {
                fileName = "Charge" + count + "_Mark2.csv";
            }
            if (mngInstance.Pass == false && mngInstance.Marks2 == true)
            {
                fileName = "DisCharge" + count + "_Mark2.csv";
            }

            mngInstance.FileName = fileName;

            ObservingData.Add(mngInstance);
        }

I assume your data file is correct. And you will sort ObservingData list by FileName before exporting it to excel.

Hope this helps.


问:
"Missing :action key on routes definition" in Rails 5
I recently updated my rails from 4.1.5 to 5.1.2

My routes.rb file:

```<code>namespace :loading do
  get :index, action: :index
  root :to => :index
end
</code>```

In 4.1.5 this works well. But after update to 5.1.2, I'm getting

```<code>Missing :action key on routes definition, please check your routes.
</code>```

Please help me ;(

Solved.

replace

```<code>root :to => :index
</code>```

to

```<code>root :action => :index
</code>```

答:
You have to mention the controller_name with action_name

In 5.1.2, a Symbol will map directly to an action but you must also specify the controller to use.

Corrected routes:

routes.rb

```<code>  Rails.application.routes.draw do
    namespace :loading do
      get :index => "loading_controller#index" #"controller_name#action_name"
      root :to => "loading_controller#index"
    end
  end
</code>```

Body:
I recently updated my rails from 4.1.5 to 5.1.2

My routes.rb file:

namespace :loading do
  get :index, action: :index
  root :to => :index
end

In 4.1.5 this works well. But after update to 5.1.2, I'm getting

Missing :action key on routes definition, please check your routes.

Please help me ;(

Solved.

replace

root :to => :index

to

root :action => :index

Body:
You have to mention the controller_name with action_name

In 5.1.2, a Symbol will map directly to an action but you must also specify the controller to use.

Corrected routes:

routes.rb

  Rails.application.routes.draw do
    namespace :loading do
      get :index => "loading_controller#index" #"controller_name#action_name"
      root :to => "loading_controller#index"
    end
  end


问:
How to fix textContent as undefined inside of for loop?
When i run the code below, it says "Cannot read property 'textContent' of undefined". Even onclick, addEventListener, length and much more says undefined! How can i fix this?

Here's the code:

```<code><div id = "dropdown-content" class = "d-con">
    <a href = "#">America</a>
    <a href = "#">Canada</a>
    <a href = "#">Rio</a>
</div>
</code>```

And The javaScript:

```<code>(function(){
    var i;
    var dropdown = document.getElementsByClassName('d-con');
    for(i = 0; i <= dropdown.length; i = i + 1){
        alert(dropdown[i].textContent);
    }
}());
</code>```

答:
Your only problem here is that your i counter reaches dropdown.length and dropdown[dropdown.length] is undefined, in other words you are trying to access an undefined element in the dropdown array.

That's why your code alerts the first 3 elements then throws the error, when it tries to access this undefined element.

Solution:

In the for loop your condition should be i < dropdown.length and not i <= dropdown.length.

```<code>(function() {
  var i;
  var dropdown = document.getElementsByClassName('d-con');
  for (i = 0; i < dropdown.length; i++) {
    alert(dropdown[i].textContent);
  }
}());
</code>```

Demo:

(function() {
  var i;
  var dropdown = document.getElementsByClassName('d-con');
  for (i = 0; i < dropdown.length; i++) {
    alert(dropdown[i].textContent);
  }
}());```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="dropdown-content" class="d-con">
  America
  Canada
  Rio
</div></code>```

Body:
When i run the code below, it says "Cannot read property 'textContent' of undefined". Even onclick, addEventListener, length and much more says undefined! How can i fix this?

Here's the code:

    America
    Canada
    Rio

And The javaScript:

(function(){
    var i;
    var dropdown = document.getElementsByClassName('d-con');
    for(i = 0; i <= dropdown.length; i = i + 1){
        alert(dropdown[i].textContent);
    }
}());

Body:
Your only problem here is that your i counter reaches dropdown.length and dropdown[dropdown.length] is undefined, in other words you are trying to access an undefined element in the dropdown array.

That's why your code alerts the first 3 elements then throws the error, when it tries to access this undefined element.

Solution:

In the for loop your condition should be i < dropdown.length and not i <= dropdown.length.

(function() {
  var i;
  var dropdown = document.getElementsByClassName('d-con');
  for (i = 0; i < dropdown.length; i++) {
    alert(dropdown[i].textContent);
  }
}());

Demo:

(function() {
  var i;
  var dropdown = document.getElementsByClassName('d-con');
  for (i = 0; i < dropdown.length; i++) {
    alert(dropdown[i].textContent);
  }
}());

<div id="dropdown-content" class="d-con">
  <a href="#">America</a>
  <a href="#">Canada</a>
  <a href="#">Rio</a>
</div>