2013-03-22 20 views
0

我必須加載一個圖像的圖像按鈕上create.I寫下面的代碼。圖像沒有加載時,它在UI.What我做錯了。這是我的主要活動,我在其他活動中繼承了這一點。無法加載imagebutton上創建方法的圖像

super.onCreate(savedInstanceState); 
setContentView(R.layout.activity_master_page); 
TheContext = this; 
ImageButton ThePosLogoL=(ImageButton)findViewById(R.id.btnposlogo); 
ThePosLogoL.setBackgroundResource(R.drawable.smalllogo); 

這裏是我的按鍵佈局

<ImageButton 
android:id="@+id/btnposlogo" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@null" 
android:layout_centerVertical="true" 
android:layout_alignParentLeft="true" /> 
+3

刪除的android:背景= 「@空」 – 2013-03-22 06:44:55

回答

2
ThePosLogoL.setImageResource(R.drawable.smalllogo); 
+0

它不是爲我工作 – nks 2013-03-22 07:10:30

+0

把staatic圖像中的XML文件,並檢查它是否是DISPLY或而不是 – 2013-03-22 07:12:06

+0

多數民衆贊成在工作,我的問題是我必須將圖像更改爲從數據庫中讀取....我想在繼承這個主類的另一個類中使用相同的代碼..並且它的工作 – nks 2013-03-22 07:31:16