我正在尝试创建像ImageButton这样的按钮 . 并面临一个棘手的问题 . 应用setImageBitmap后,使用ImageView没有任何反应 . 位图本身包含图像(非空) . 而且,我在程序中的其他地方使用相同的函数(ImageManager.getImage("menu",id)),它必须包含ListView适配器中的Bitmap,工作正常 .

for( int i = 0; i < MenuArray.size(); i++)
        {
            View buttonView = MainActivity.getLayoutInflater().inflate(R.layout.top_button, MenuLayout, false);
            buttons[i] = (ImageView) buttonView.findViewById(R.id.imageForeground);
            ImageView imageBackground = (ImageView) buttonView.findViewById(R.id.imageBackground);
            imageBackground.setImageBitmap(ImageManager.getImage("menu", MenuArray.get(i).id));

            MenuLayout.addView(buttonView);
        }

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_margin="2dp" >
    <ImageView
        android:id="@+id/imageBackground"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/cart_item" />

    <ImageView
        android:id="@+id/imageForeground"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/button_selector" />
</RelativeLayout>