Dynamically adding a button to RelativeLayout not working correctly
问题 My goal is to add a number of buttons (in a 4 column grid) to a RelativeLayout depending on how many "items" are in the database. When I was first learning how to add buttons to a RelativeLayout I just created 6 static buttons and added them the following way (ItemButton is simple class that extends Button): private void loadItemButtons2(){ itemButtonLayout = (RelativeLayout)findViewById(R.id.itemButtonLayout); itemButtonLayout.removeAllViews(); ArrayList<Item> items = db.getAllActiveItems();