横滑

for (int i=0;i<titles.length;i++){
    textView = new TextView(this);
    textView.setText(titles[i]);
    textView.setTextSize(20);
    textView.setId(i);
    textView.setTextColor(Color.BLACK);

    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
                textView.setTextColor(Color.RED);
            int id = v.getId();
            viewPager.setCurrentItem(id);
        }
    });
    if (i==0){
        textView.setTextColor(Color.RED);
    } else {
        textView.setTextColor(Color.BLACK);
    }
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(20,50,20,10);
    linearLayout.addView(textView,layoutParams);
}
class ContentModel {
    private int imageView;
    private String text;
    private int id;

}

list = new ArrayList<>();
list.add(new ContentModel(R.mipmap.ic_launcher, "新闻", 1));

 Gson gson = new Gson();
                News news = gson.fromJson(json, News.class);
                List<News.BannerBean> banner = news.getBanner();
                for (int i=0;i<banner.size(); i++){
                    String image_url = banner.get(i).getImage_url();
                    ImageView imageView = new ImageView(getActivity());
                    DisplayImageOptions options = ImageLoaderUtils.getOptions();
                    ImageLoader.getInstance().displayImage(image_url,imageView,options);
                    list.add(imageView);
                }
                MyAdapter adapter = new MyAdapter(getActivity(),list);
                vp.setAdapter(adapter);
            }else if (msg.what == 1){
                int i = vp.getCurrentItem();
                vp.setCurrentItem(++i);
                handler.sendEmptyMessageDelayed(1,1000);

public class MyAdapter extends PagerAdapter{
    private Context context;
    private List<ImageView> list;

    public MyAdapter(Context context, List<ImageView> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ImageView imageView = list.get(position % list.size());
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        container.addView(imageView);
        return imageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}

View view = View.inflate(HomepageActivity.this,R.layout.popup_windowone,null);

PopupWindow popupWindow = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                popupWindow.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
                popupWindow.setOutsideTouchable(true);
                popupWindow.setTouchable(true);
                popupWindow.showAsDropDown(v);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值