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">
android: id = "@ + id / mian_tongbu"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: layout_alignParentLeft = "true"
android: layout_centerVertical = "true"
android: background = "@ drawable / button_tongbu_selector" />android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: layout_centerHorizontal = "true"
android: layout_centerVertical = "true"
android: text = "@ string / main_titlebar_name"
android: textColor = "# ffffff"
android: textSize = "20dp" />
android: id = "@ android: id / tabhost"
android: layout_width = "match_parent"
android: layout_height = "wrap_content">android: id = "@ android: id / tabcontent"
android: layout_width = "0dp"
android: layout_height = "0dp"
android: layout_weight = "0" />
android: id = "@ + id / realtabcontent"
android: layout_width = "fill_parent"
android: layout_height = "0dp"
android: layout_weight = "1" />
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