0
我試圖在另一個佈局上設置ImageView 的背景圖像。另一個佈局是表格行佈局。這裏是代碼在另一個佈局上爲ImageView設置圖像
ImageView pdfImage;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
LayoutInflater inflater = (LayoutInflater) context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.listlayout, null);
pdfImage = (ImageView)ll.findViewById(R.id.pdfImage);
pdfImage.setBackgroundResource(R.drawable.pdflogo);
pdflogo
沒有被設置爲圖像。它只是空白。我怎樣才能做到這一點?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout android:layout_width="wrap_content" android:layout_height="50dp">
<ImageView android:id="@+id/selfImage" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/selfhelpnavbar"/>
<ImageView android:id="@+id/logoImage" android:layout_width="70dp" android:layout_height="46dp" android:layout_alignParentTop="true" android:layout_alignParentRight="true" />
<ImageView android:id="@+id/mainLogo" android:layout_width="50dp" android:layout_height="46dp" android:background="@drawable/mainlogo" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"/>
</RelativeLayout>
<ListView
android:id="@+id/helpList"
android:layout_width="wrap_content"
android:layout_height="387dp" >
</ListView>
<!-- Tab Bar -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/helpButton"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:background="@drawable/selfhelptab_selected"
android:layout_weight="1.0"
android:onClick="onClick"
android:clickable="true"/>
<ImageButton
android:id="@+id/eButton"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:background="@drawable/eapservicestab"
android:layout_weight="1.0"
android:onClick="onClick"
android:clickable="true"/>
<ImageButton
android:id="@+id/mailButton"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:background="@drawable/mailtab"
android:layout_weight="1.0"
android:onClick="onClick"
android:clickable="true"/>
<ImageButton
android:id="@+id/gethelpButton"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:background="@drawable/gethelptab"
android:layout_weight="1.0"
android:onClick="onClick"
android:clickable="true"/>
<ImageButton
android:id="@+id/moreButton"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:background="@drawable/moretab"
android:layout_weight="1.0"
android:onClick="onClick"
android:clickable="true"/>
</LinearLayout></LinearLayout>
如果我設置了內容查看到佈局,然後我原來的佈局顯示不出來。這個'listlayout'就是我的表中的行。見圖 – BigT 2012-07-12 14:41:10
請提供help.xml結構 – 2012-07-12 14:45:05
我已經添加了xml結構 – BigT 2012-07-12 17:02:09