Found this strange behaviour of Handlers in android <p>I just wrote a code which adds several views, each using a handler. These are added using a for-loop. These add just correctly. Then I tried to add a button AFTER the for loop without using handler. This time the button was shown on the top of the layout i.e BEFORE the items added in for loop. This does not happen if I add the button using handler.</p> <p>So, if I use the following code with a handler after the loop then the button is added on the bottom of the layout:</p> <pre><code> private void fillFeedWithData(final List&lt;ParseObject&gt; feedObjectList) { LayoutInflater inflaterOfFeedItem = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i &lt; feedObjectList.size(); i++) { final String jokeTitle = feedObjectList.get(i).getString("content"); final View cvFeedItem = inflaterOfFeedItem.inflate(R.layout.feed_item_theme_card, null); final TextView tvJoke = (TextView) cvFeedItem.findViewById(R.id.tvFeedJoke); Handler h2 = new Handler(); Runnable update2 = new Runnable() { public void run() { tvJoke.setText(jokeTitle); llFragmentFeedParent.addView(cvFeedItem); // llFragmentFeedParent is acquired in OnCreate() method } }; h2.post(update2); } final Button bNext = new Button(this); bNext.setText("Next &gt;"); bNext.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); Handler h3 = new Handler(); Runnable update3 = new Runnable() { public void run() { llFragmentFeedParent.addView(bNext); } }; h3.post(update3); } </code></pre> <p>If I used the following code after the loop then the button is added on the top of the layout:</p> <pre><code> Button bNext = new Button(this); bNext.setText("Next &gt;"); bNext.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); llFragmentFeedParent.addView(bNext); </code></pre> <p>So now my app is working as intended with the handler but I am concerned as to why this was happening. I think the handlers are mixing up the timings/sequence of execution? If I keep using the logic, is it possible that the button might, in a slow mobile phone, appear on top or even in between the items added in the loop?</p>