Android – what is android:supportsRtl=”true” for?

android:supportsRtl="true"

I always thought what is this for? Now I found what for. It is for supporting Arabic, Urdu, Hebrew languages. Because those languages are written from right to left. If you set supportsRtl true, your layout will be mirrored from right to left. So you do not have to create special layout for it. If you set false, your layout remain same no matter what language is used.

This is supported from API 17 – Android 4.2.

Java – Monty Hall problem prove

Wikipedia: Suppose you’re on a game show, and you’re given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what’s behind the doors, opens another door, say No. 3, which has a goat. He then says to you, “Do you want to pick door No. 2?” Is it to your advantage to switch your choice?

Vos Savant’s response was that the contestant should switch to the other door (vos Savant 1990a). Under the standard assumptions, contestants who switch have a 2/3 chance of winning the car, while contestants who stick to their initial choice have only a 1/3 chance.

Using Java, I tested this problem for 10000 times and I found that wins percentage is 33% when player does not change their decision after host opened one of door without car. If player changes decision, wins percentage is 66% which is double comparing to if player does not change.

Continue reading Java – Monty Hall problem prove

WordPress – Which syntax highlighter to choose?

CodeColorer

    /**
     * The {@link ViewPager} that will host the section contents.
     */

    private ViewPager mViewPager;
    public static int seasonId = 741;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // progress = (ProgressBar) findViewById(R.id.progress);

        gson = new GsonBuilder().create();
        setTitle(getString(R.string.app_name));

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }



Crayon Syntax Highlighter

    /**
     * The {@link ViewPager} that will host the section contents.
     */
    private ViewPager mViewPager;
    public static int seasonId = 741;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // progress = (ProgressBar) findViewById(R.id.progress);

        gson = new GsonBuilder().create();
        setTitle(getString(R.string.app_name));

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }



Syntax Highlighter Evolved

    /**
     * The {@link ViewPager} that will host the section contents.
     */
    private ViewPager mViewPager;
    public static int seasonId = 741;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // progress = (ProgressBar) findViewById(R.id.progress);

        gson = new GsonBuilder().create();
        setTitle(getString(R.string.app_name));

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }

Prismatic

    /**
     * The {@link ViewPager} that will host the section contents.
     */
    private ViewPager mViewPager;
    public static int seasonId = 741;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // progress = (ProgressBar) findViewById(R.id.progress);

        gson = new GsonBuilder().create();
        setTitle(getString(R.string.app_name));

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }
    /**
     * The {@link ViewPager} that will host the section contents.
     */
    private ViewPager mViewPager; 


    public static int seasonId = 741;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // progress = (ProgressBar) findViewById(R.id.progress);

        gson = new GsonBuilder().create();
        setTitle(getString(R.string.app_name));

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }
    /**
     * The {@link ViewPager} that will host the section contents.
     */
    private ViewPager mViewPager;
    public static int seasonId = 741;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // progress = (ProgressBar) findViewById(R.id.progress);

        gson = new GsonBuilder().create();
        setTitle(getString(R.string.app_name));

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }
    /**
     * The {@link ViewPager} that will host the section contents.
     */
    private ViewPager mViewPager; 


    public static int seasonId = 741;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // progress = (ProgressBar) findViewById(R.id.progress);

        gson = new GsonBuilder().create();
        setTitle(getString(R.string.app_name));

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }