我开发了一个简单的 Android 应用程序,其中我使用 Fragments 实现了选项卡...但我无法显示选项卡的图像..我附上了下面的源代码..请让我知道错误是什么.. .
我的活动类 TabDemoFragmentActivity.java
public class TabDemoFragmentActivity extends FragmentActivity {
/**
* Instance variable of type {@link FragmentTabHost}
*/
private FragmentTabHost fragmentTabHost;
/**
* This is a call back method, which gets invoked
* when the instance of this class is created.
*
* <p>
* This method is used to set the tab host and
* add the tab host fragments to the screen,
* which acts as a UI.
* </P>
*/
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_fragment_main);
fragmentTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
fragmentTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
fragmentTabHost.addTab(fragmentTabHost.newTabSpec("DropCall Details").setIndicator("DropCall Details",
getResources().getDrawable(R.drawable.drop_call_image)).setContent(intent), QoSDropCallDetailsFragment.class, null);
fragmentTabHost.addTab(fragmentTabHost.newTabSpec("Network Details").setIndicator("Network Details",
getResources().getDrawable(R.drawable.network_details)), QoSNetworkDetailsFragment.class, null);
}
}
我的 XML 文件
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="@+id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="50" />
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
此处未显示图像..请让我知道如何在选项卡中显示图像..谢谢