public class TwoplayerActivity extends AppCompatActivity {
GridLayout gridLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
---
gridlayout= (GridLayout)findViewById(R.id.gridLayout);
gridLayout.setBackgroundResource(R.drawable.boards2);
}
}
这不起作用。我认为这适用于其他布局。
答案 0 :(得分:0)
尝试:
gridLayout.setBackground(getResources().getDrawable(R.drawable.boards2));
但它也应与.setBackgroundResource(...)
一起使用。