fragmentTabHostDemo | FragmentTabHost的使用 - if

 by   tome34 Java Version: 1.0.0 License: No License

kandi X-RAY | fragmentTabHostDemo Summary

kandi X-RAY | fragmentTabHostDemo Summary

fragmentTabHostDemo is a Java library. fragmentTabHostDemo has no bugs, it has no vulnerabilities, it has build file available and it has low support. You can download it from GitHub.

if (android.os.Build.VERSION.SDK_INT > 10) { // 去除分割线 mTabHost.getTabWidget().setShowDividers(0); } 初始化TabHost.TabSpec以及Fragment //创建TabSpec TabHost.TabSpec tabSpec1 = mMainTabhost.newTabSpec("tag1"); tabSpec1.setIndicator("label1");. //添加TabSpec到TabHost mMainTabhost.addTab(tabSpec1, TabSpec1Fragment.class, null); 分析常见一个TabSpec需要啥 public int noteId;//文字id,tag文字 public int iconId;//图标 public Class clz;//对应的fragment 普通类的方式封装 class MainBottomBean { public int noteId;//文字id,tag文字 public int iconId;//图标 public Class clz;//对应的fragment. 枚举方式封装创建TabSpec需要的内容 NEWS(0, R.string.main_tab_name_news, R.drawable.tab_icon_new, GeneralViewPagerFragment.class),. TWEET(1, R.string.main_tab_name_tweet, R.drawable.tab_icon_tweet, TweetsViewPagerFragment.class),. QUICK(2, R.string.main_tab_name_quick, R.drawable.tab_icon_new, null),. EXPLORE(3, R.string.main_tab_name_explore, R.drawable.tab_icon_explore, ExploreFragment.class),. ME(4, R.string.main_tab_name_my, R.drawable.tab_icon_me, MyInformationFragment.class); 引入SmartTabLayout 依赖. //option,设置indicator两种效果 //下划线 app:stlindicatorColor="#06ed63" app:stlindicatorThickness="4dp" app:stl_indicatorGravity="bottom". //滑块 app:stlindicatorColor="#33000000" app:stlindicatorCornerRadius="18dp" app:stlindicatorThickness="36dp" app:stlindicatorGravity="center". BaseTabFragment抽取 带有tab标签页面的Fragment 分析NewsFragment对应的adapter 分析MyFragmentStatePagerAdapter. class MyFragmentStatePagerAdapter extends FragmentStatePagerAdapter {. class MyFragmentStatePagerAdapter extends FragmentStatePagerAdapter {. class TabInfo { public Class clz; public Bundle args; public String title; } 解耦完成. private List mTabInfos = new ArrayList<>(); Context mContext; ViewPager mViewPager; SmartTabLayout mTab;. public void setTabInfos(List tabInfos) { mTabInfos = tabInfos; notifyDataSetChanged(); mTab.setViewPager(mViewPager); }. public MyFragmentStatePagerAdapter(FragmentManager fm, Context context, ViewPager viewPager, SmartTabLayout tab) { super(fm); mContext = context; mViewPager = viewPager; mTab = tab; }. @Override public Fragment getItem(int position) { TabInfo info = mTabInfos.get(position); return Fragment.instantiate(mContext, info.clz.getName(), info.args); }. @Override public int getCount() { if (mTabInfos != null) { return mTabInfos.size(); } return 0; }. @Override public CharSequence getPageTitle(int position) { System.out.println("title"); TabInfo info = mTabInfos.get(position); return info.title; } 修改NewsFragment位如下. public abstract class BaseTabFragment extends BaseFragment { @Bind(R.id.tab) SmartTabLayout mTab; @Bind(R.id.viewpager) ViewPager mViewpager; private String[] mTitleArr;. @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_tabs, null); }. @Override public void initData() { //模拟数据 MyFragmentStatePagerAdapter adapter = new MyFragmentStatePagerAdapter(getChildFragmentManager(), mContext, mViewpager, mTab); mViewpager.setAdapter(adapter); mTab.setViewPager(mViewpager);. @NonNull public abstract List onInitTabInfo(); }.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              fragmentTabHostDemo has a low active ecosystem.
              It has 2 star(s) with 0 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              fragmentTabHostDemo has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of fragmentTabHostDemo is 1.0.0

            kandi-Quality Quality

              fragmentTabHostDemo has no bugs reported.

            kandi-Security Security

              fragmentTabHostDemo has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              fragmentTabHostDemo does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              fragmentTabHostDemo releases are available to install and integrate.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed fragmentTabHostDemo and discovered the below as its top functions. This is intended to give you an instant insight into fragmentTabHostDemo implemented functionality, and help decide if they suit your requirements.
            • Initializes the widget
            • Initializes the tab host
            Get all kandi verified functions for this library.

            fragmentTabHostDemo Key Features

            No Key Features are available at this moment for fragmentTabHostDemo.

            fragmentTabHostDemo Examples and Code Snippets

            No Code Snippets are available at this moment for fragmentTabHostDemo.

            Community Discussions

            No Community Discussions are available at this moment for fragmentTabHostDemo.Refer to stack overflow page for discussions.

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install fragmentTabHostDemo

            You can download it from GitHub.
            You can use fragmentTabHostDemo like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the fragmentTabHostDemo component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/tome34/fragmentTabHostDemo.git

          • CLI

            gh repo clone tome34/fragmentTabHostDemo

          • sshUrl

            git@github.com:tome34/fragmentTabHostDemo.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Java Libraries

            CS-Notes

            by CyC2018

            JavaGuide

            by Snailclimb

            LeetCodeAnimation

            by MisterBooo

            spring-boot

            by spring-projects

            Try Top Libraries by tome34

            frameDemoMo2

            by tome34C++

            frameMo

            by tome34Java

            mvpFrame

            by tome34Java

            AS3.0_settings

            by tome34Java

            CommonWidget

            by tome34Java