扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
这篇文章将为大家详细讲解有关Android应用中怎么在底端显示选项卡,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
创新互联是工信部颁发资质IDC服务器商,为用户提供优质的眉山联通机房服务
1.layout 文件
<?xml version="1.0" encoding="utf-8" ?>
2.Java 文件
import android.app.ActivityGroup; import android.graphics.Color; import android.os.Bundle; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.TabHost; import android.widget.TextView; public class TabBottom extends ActivityGroup { public static TabHost myTabhost; private LayoutParams title_params = new LayoutParams(120, 50); private LayoutParams content_params = new LayoutParams(158, 50); private LinearLayout titleLayout, showViewLayout, titleLayout1, showViewLayout1, titleLayout2, showViewLayout2, titleLayout3, showViewLayout3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bottomtab); myTabhost = (TabHost) findViewById(R.id.edit_item_tab_host); myTabhost.setup(this.getLocalActivityManager()); titleLayout = (LinearLayout) findViewById(R.id.titleLayout_person_check_road_add); showViewLayout = (LinearLayout) findViewById(R.id.layout_person_check_road_add); titleLayout1 = (LinearLayout) findViewById(R.id.titleLayout_person_check_road_add1); showViewLayout1 = (LinearLayout) findViewById(R.id.layout_person_check_road_add1); titleLayout2 = (LinearLayout) findViewById(R.id.titleLayout_person_check_road_add2); showViewLayout2 = (LinearLayout) findViewById(R.id.layout_person_check_road_add2); titleLayout3 = (LinearLayout) findViewById(R.id.titleLayout_person_check_road_add3); showViewLayout3 = (LinearLayout) findViewById(R.id.layout_person_check_road_add3); myTabhost.addTab(myTabhost .newTabSpec("One") .setIndicator("收件箱", getResources().getDrawable(R.drawable.icon)) .setContent(R.id.widget_layout_Blue)); myTabhost.addTab(myTabhost .newTabSpec("Two") .setIndicator("发件箱", getResources().getDrawable(R.drawable.icon)) .setContent(R.id.widget_layout_green)); myTabhost.addTab(myTabhost .newTabSpec("Three") .setIndicator("垃圾箱", getResources().getDrawable(R.drawable.icon)) .setContent(R.id.widget_layout_red)); myTabhost.addTab(myTabhost .newTabSpec("Four") .setIndicator("发送", getResources().getDrawable(R.drawable.icon)) .setContent(R.id.widget_layout_yellow)); showInLayout(); showInLayout1(); showInLayout2(); showInLayout3(); } /* * 填充第一个选项卡页面 */ private void showInLayout() { for (int i = 0; i < 10; i++) { String condName = "名称显示1"; TextView tv = new TextView(this); tv.setTextColor(Color.WHITE); tv.setTextSize(16); tv.setLayoutParams(title_params); tv.setText(condName + ":"); titleLayout.addView(tv); EditText tv1 = new EditText(this); tv1.setTextSize(16); tv1.setLayoutParams(content_params); tv1.setText(condName); showViewLayout.addView(tv1); } } private void showInLayout1() { for (int i = 0; i < 10; i++) { String condName = "名称显示2"; TextView tv = new TextView(this); tv.setTextColor(Color.WHITE); tv.setTextSize(16); tv.setLayoutParams(title_params); tv.setText(condName + ":"); titleLayout1.addView(tv); TextView tv1 = new TextView(this); tv1.setTextColor(Color.WHITE); tv1.setTextSize(16); tv1.setLayoutParams(content_params); tv1.setText(condName + ":"); showViewLayout1.addView(tv1); } } private void showInLayout2() { for (int i = 0; i < 10; i++) { String condName = "名称显示3"; TextView tv = new TextView(this); tv.setTextColor(Color.WHITE); tv.setTextSize(16); tv.setLayoutParams(title_params); tv.setText(condName + ":"); titleLayout2.addView(tv); TextView tv1 = new TextView(this); tv1.setTextColor(Color.WHITE); tv1.setTextSize(16); tv1.setLayoutParams(content_params); tv1.setText(condName + ":"); showViewLayout2.addView(tv1); } } private void showInLayout3() { for (int i = 0; i < 10; i++) { String condName = "名称显示4"; TextView tv = new TextView(this); tv.setTextColor(Color.WHITE); tv.setTextSize(16); tv.setLayoutParams(title_params); tv.setText(condName + ":"); titleLayout3.addView(tv); TextView tv1 = new TextView(this); tv1.setTextColor(Color.WHITE); tv1.setTextSize(16); tv1.setLayoutParams(content_params); tv1.setText(condName + ":"); showViewLayout3.addView(tv1); } } }
关于Android应用中怎么在底端显示选项卡就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流