Toolbar together with Tabhost

Asked

Viewed 97 times

0

Hello. I have created two tabs in my application. Open Request and Closed Orders. But in this Activity Toolbar does not take.

Abas

Code:

public class PedidoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pedido);

    TabHost tabHost=(TabHost)findViewById(R.id.tabHost);
    tabHost.setup();

    TabSpec spec1=tabHost.newTabSpec("EM ABERTO");
    spec1.setContent(R.id.tab1);
    spec1.setIndicator("EM ABERTO" ,getResources().getDrawable(R.drawable.ic_menu_camera));

    TabSpec spec2=tabHost.newTabSpec("FECHADO");
    spec2.setIndicator("FECHADO" ,getResources().getDrawable(R.drawable.ic_menu_camera));
    spec2.setContent(R.id.tab2);


    tabHost.addTab(spec1);
    tabHost.addTab(spec2);


}

On this screen does not look like other, example:

inserir a descrição da imagem aqui

I would like to add a Toolbar on this screen as well. For in this Toolbar I want to add the back button.

1 answer

0

I wish I could comment, because the answer would be short, but I can’t because I don’t have enough rest.

My advice to create a TabbedActivity with Action Bar Tabs this activity has a ViewPager and a toolbar .

I think it would make your job a lot easier, some doubt says!

Good job

  • I couldn’t understand very well, could you give me more tips? If possible you can answer in another language, maybe English. I understand English well. Thank you.

  • I am Portuguese, I will explain in a very brief way: There is an activity called Tabbed Activity, use this activity to get what you want. this activity contains: tabHost, viewPager, Toolbar and fba (floatting button) Explore this activity a little, it is very easy to use and practical, if you have any questions about this activity says

Browser other questions tagged

You are not signed in. Login or sign up in order to post.