1

我使用 setbackgroundresource 设置 LinearLayout 的背景,但它不能显示在活动中。

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);       
        sp = getSharedPreferences("config", MODE_PRIVATE);
        bgpic = sp.getInt("bgpic", 3);
        ll_main = (LinearLayout) findViewById(R.id.ll_main);
        Log.i(TAG, "图片"+imageIds[bgpic]);
        Log.i(TAG, "图片"+R.drawable.bg2);
        ll_main.setBackgroundResource(imageIds[bgpic]);
        ll_main.setBackgroundDrawable(new BitmapDrawable());

以上是部分代码。

4

0 回答 0