package com.example.tabdemo;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class TabDemoActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab_demo);
TabHost tabHost=getTabHost();
LayoutInflater layoutInflater=LayoutInflater.from(this);
View view=layoutInflater.inflate(R.layout.activity_tab_demo, tabHost.getTabContentView(),true);
TabSpec spec1=tabHost.newTabSpec("tab1");
spec1.setIndicator("tab1");
spec1.setContent(R.id.view1);
tabHost.addTab(spec1);
TabSpec spec2=tabHost.newTabSpec("tab2");
spec2.setIndicator("tab2");
spec2.setContent(R.id.view2);
tabHost.addTab(spec2);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.tab_demo, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
http://blog.csdn.net/lijianhua910829/article/details/10074987?locationNum=8&fps=1
FrameLayout 布局里的控件会都在屏幕左上角堆着,后面的控件会覆盖前面的
你两个TextView都设置的宽高太大了....你设成wrap_content试试
framelayout--帧布局,起点默认左上角,你不设置位置当然在一起了
居然还有人用tabhost...........................................
我记得tabhost配合使用不是这样用的tabhost好像可以实现fragment切换的效果但是下面的好像是activity。这个用法在疯狂Java里面似乎有啊
也是醉了 ... 俩个TextView都 match_parent了 不重叠才怪
你懂个锤子,人家是要分别显示两页内容,跟match_parent有什么关系。