How to create Button Dynamically in android?

后端 未结 5 907
抹茶落季
抹茶落季 2020-11-30 05:02

\"Links\"

I want to create a page like this. these 7 buttons are already exist but if user want to add more cat

5条回答
  •  無奈伤痛
    2020-11-30 05:55

    this is for create button dynamically in android

    LinearLayout row2 = (LinearLayout) findViewById(R.id.hll2);
    Button ivBowl = new Button(this);
    ivBowl.setText("hi");
    LinearLayout.LayoutParams layoutParams = new  LinearLayout.LayoutParams(70, 70);
    layoutParams.setMargins(5, 3, 0, 0); // left, top, right, bottom
    ivBowl.setLayoutParams(layoutParams);
    row2.addView(ivBowl);
    

提交回复
热议问题