Spinner in tab is not shown
This is my activity code
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.input_transaction);
tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec(getString(R.string.tab_in))
.setIndicator(getString(R.string.tab_in))
.setContent(R.id.tab_in));
tabHost.addTab(tabHost.newTabSpec(getString(R.string.tab_out))
.setIndicator(g开发者_StackOverflow中文版etString(R.string.tab_out))
.setContent(R.id.tab_out));
tabHost.addTab(tabHost.newTabSpec(getString(R.string.tab_transfer))
.setIndicator(getString(R.string.tab_transfer))
.setContent(R.id.tab_transfer));
tabHost.setCurrentTabByTag(getString(R.string.tab_out));
}
Layout part for current tab
<LinearLayout android:id="@+id/tab_out"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="@string/planet_prompt"/>
<Spinner android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/planet_prompt"/>
</LinearLayout>
And screen of what I got
So, what should I do to make spinner present in tab, and why is it happening? Thanks!
You've told your text view to "Fill Parent", so it has pushed the spinner out.
Add this to both your spinner and textview XML:
android:layout_weight="1"
精彩评论