Android UI TabActivity issue

后端 未结 2 1056
南旧
南旧 2020-12-06 08:19

I am trying to implement the following background for the application... \"enter

For t

2条回答
  •  失恋的感觉
    2020-12-06 09:07

    For this you must use Custom Tabs ,here is the Code try this :

      tabHost= getTabHost();
      tabHost.addTab(tabHost.newTabSpec("tab1").setContent(new Intent(this, Activity2.class)).setIndicator(prepareTabView("Names",R.drawable.icon)));
    

    where prepareTabView is method that Inflate View. Then Inflate a view like this :

        private View prepareTabView(String text, int resId) {
             View view = LayoutInflater.from(this).inflate(R.layout.tabs, null);
             ImageView iv = (ImageView) view.findViewById(R.id.TabImageView);
             TextView tv = (TextView) view.findViewById(R.id.TabTextView);
             iv.setImageResource(resId);
             tv.setText(text);
             return view;
        }
    

    Where tabs XML will look like this :

    
    
    
    
    
    
    
     
    

    Then now add your backgroung color as you like..

提交回复
热议问题