Notes tab

Tabs are used to implement a multi-tab user interface, through which a complex dialog box can be divided into several tabs, to realize the classified display and management of information.
Android use tabs cannot use a specific component in the XML file Add
in Add tabs in XML file:

a) Add the TabHost, TabWidget and FrameLayout components required to implement the tab in the layout file
b) Write the XML layout file corresponding to the content to be displayed in each tab
c) In the Activity, obtain and initialize the TabHost component
d) As TabHost Object add tab

Example:

  1. Change the layout manager in the activity_main.xml file to TabHost
  2. Add a layout manager to the TabHost tag in the activity_main.xml file to load the TabWidget tag group and other components
  3. Add TabWidget label group in activity_main.xml file
  4. Create a new xml file to record the content of each tab page, no need to write TabHost component at this time
  5. Create TabHost object in Activity and get TabHost object
  6. Initialize the component with setup()
  7. Declare and instantiate the LayoutInflater object
  8. Use the inflate(R, folder. file name, TabHost object.getTabContentView()) method to load a layout file
  9. Use the TabHost object. addTab(TabHost.newTabSpec("tab page xml file")
    .setIndicator("tab page name")
    .setContent(R.id. layout manager id in the tab page));

Guess you like

Origin blog.csdn.net/qq_42823109/article/details/94360355
Tab
Tab
Tab
Tab