我正在尝试在另一个布局上设置 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>