欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

知识点整理

程序员文章站 2022-07-12 10:21:44
...

TabLayout 的使用:::

定义List集合 ,集合添加数据,

tabNews.setTabMode(TabLayout.MODE_FIXED);
tabNews.setTabTextColors(ColorStateList.valueOf(Color.BLACK));

与ViewPager联合 适配器添加下面方法

getPageTitle

添加视图

tabNews.setupWithViewPager(vpNews);

________________________________________________________________

Fragment 的用法:::

getSupportFragmentManager();

manager.beginTransaction.add(R.id.fragment, fragment)......hide ....commit

tvOne.setBackgroundColor(index == 0 ? Color.BLACK : Color.WHITE);

_____________________________________________________________________________

XListView  ::::

xlvList.setPullRefreshEnable(true);
xlvList.setPullLoadEnable(true);

 

handler.postDelayed(new Runnable() {
    @Override
    public void run() {

        xlvList.stopRefresh();
        xlvList.stopLoadMore();
    }
}, 2000);

____________________________________________________________________________________________

ViewPager 加载图片

instantiateItem  方法里面写上
ImageView img = new ImageView(context);
img.setImageResource(ingID.get(position));
container.addView(img);

 

Fragment 静态传值

public static FragmentEmpty newInstance(String text){
    FragmentEmpty fragment = new FragmentEmpty();
    Bundle bundle = new Bundle();
    bundle.putString("param",text);
    fragment.setArguments(bundle);
    return fragment;
}
fragments.add(new FragmentOne());
for (int i = 1; i < titles.size(); i++) {
    FragmentEmpty instance = FragmentEmpty.newInstance(titles.get(i));
    fragments.add(instance);
}