Display a contextmenu when clicking a tab, in the

2019-09-15 02:22发布

问题:

I need to display something like a context menu when a certain tab is pressed, something like this :

Is it possible? I know that when a tab is declared it must be set an Intent, and I want to display this context menu in the same screen with the tabs (the same activity). Need some help. Any idea is welcome. Thanks in advance.

EDIT : I want to say that the last tab to be something like this :

on Facebook. The last tab to have some options but the content to not be modified.

回答1:

As according to your reqiurement as u only want contex menu at Tab not other data for that tab than u there is no need to add intent type for that tab or comment that intent for that tab example like

// intent = new Intent().setClass(this, tabactivity3.class);
 spec = tabHost.newTabSpec("songs").setIndicator("Search",
                       res.getDrawable(R.drawable.act3))
                   .setContent(intent);

     tabHost.addTab(spec);

i have commented intent for tab 3 which will show context menu on behind view as previous tab data as shown image below where my ic_launcher image display is of tab 1