简体   繁体   中英

get viewpager text dynamically from mainactivity

i want to give view pager title text from mainactivity and save theme in a ArrayList<String>

this is my MainActivity.java

 //======================================================  find tablayout
        TabLayout iTabLayout = (TabLayout) findViewById(R.id.tabLayoutMainXml);

        //======================================================  adding tabs to tablayout
        iTabLayout.addTab(iTabLayout.newTab().setText("main"));
        iTabLayout.addTab(iTabLayout.newTab().setText("news"));
        iTabLayout.addTab(iTabLayout.newTab().setText("price"));

        ArrayList<String> tabtitles = new ArrayList<String>();

        tabtitles.add("==> i dont know what am i doing here <== ");

i think there is no way for this . finally this is not dynamic but it solved the problem.

 //======================================================  find tablayout
        TabLayout iTabLayout = (TabLayout) findViewById(R.id.tabLayoutMainXml);

    //======================================================  adding tabs to tablayout
    iTabLayout.addTab(iTabLayout.newTab());
    iTabLayout.addTab(iTabLayout.newTab());
    iTabLayout.addTab(iTabLayout.newTab());

    ArrayList<String> tabtitles = new ArrayList<String>();

    tabtitles.add("main");
    tabtitles.add("top");
    tabtitles.add("news");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM