Monday, May 5, 2014

FragmentTabHost a total of two labels, but not the lateral full screen


Layout code
 xmlns: tools = "http://schemas.android.com/tools" 
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "vertical">

android: id = "@ + id / main_relayout"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: background = "@ drawable / titlebarbackground"
android: padding = "10dp">





java file
 

public class MainAct extends FragmentActivity {
private FragmentTabHost mTabHost;
TabWidget tabWidget;
Button tongbu;
ContactsApp app;


private SharedPreferences sp;


@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main);


app = (ContactsApp) getApplication ();
app.cList = new ArrayList ();

bottomViwe = findViewById (R.id.all_relative);


/ / Label 1
View tabView1 = LayoutInflater.from (this). Inflate (R.layout.biaoqian1,
null);
/ / Label 2
View tabView2 = LayoutInflater.from (this). Inflate (R.layout.biaoqian2,
null);

tongbu = (Button) findViewById (R.id.mian_tongbu);

mTabHost = (FragmentTabHost) findViewById (android.R.id.tabhost);
mTabHost.setup (this, getSupportFragmentManager (), R.id.realtabcontent);

mTabHost.addTab (mTabHost.newTabSpec ("allcontacts"). setIndicator (tabView1),
AllContactsFragment.class, null);
mTabHost.addTab (mTabHost.newTabSpec ("recievecontacts"). setIndicator (tabView2),
RecentContactsFragment.class, null);
tabWidget = (TabWidget) findViewById (android.R.id.tabs);
mTabHost.invalidate ();

}

public boolean onKeyDown (int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
if (findViewById (R.id.all_relative) == null) {
return super.onKeyDown (keyCode, event);
}
if (findViewById (R.id.all_relative). getVisibility () == View.VISIBLE) {
. findViewById (R.id.all_relative) setVisibility (View.GONE);
AllContactsFragment.adapter.unShow ();
return true;
}
return super.onKeyDown (keyCode, event);

}

return super.onKeyDown (keyCode, event);

}



}


There are two tabs in this tabhost buttons;
Two labels are two view, composed by the ImageView and TextView;
I do not know why the two tabs on the big screen is fully satisfied, solving
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Image problem, set background attribute on it, knot stickers

No comments:

Post a Comment