-1

I have one Button. If i click the button, the view has added pro grammatically.So the view has created. But I want some solution with some order.

Once If i click the button,the view has added accordingly. But i want to display the newly added view is displayed in first and previously added view displayed finally.

btn_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                      addRow();
            }
        });



private void addRow(){

   View hiddenInfo = getActivity().getLayoutInflater().inflate(R.layout.layout_order_detail, main_layout, false);
    main_layout.addView(hiddenInfo);
    }
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
rajeshlawrance
  • 549
  • 2
  • 6
  • 25

1 Answers1

1

Simply specify a zero index for the new row:

main_layout.addView(hiddenInfo, 0);
Mike M.
  • 38,532
  • 8
  • 99
  • 95