0

我正在使用带有自定义图像标题的 TabActivity。打电话时

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_title);

if (resId > 0)
{
    ImageView im = (ImageView) findViewById(R.id.title_bar);
    im.setImageResource(resId);
}

“我”为空。基于其他问题,我看到不调用 setContentView 会导致这种情况,但我没有使用任何布局文件。有什么我想念的吗?

这是 my_custom_title.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_height="wrap_content"
                 android:layout_width="wrap_content"
                 android:orientation="vertical">

    <ImageView  android:src="@drawable/launch"
                android:layout_width="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:id="@+id/title_bar"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true" />
</LinearLayout>

谢谢,
拉贾特

4

1 回答 1

1

嗨拉贾特使用 setContentView(R.layout.my_custom_title);

于 2011-01-21T11:28:28.250 回答