织梦CMS - 轻松建站从此开始!

沙龙国际_沙龙国际娱乐城_沙龙国际娱乐官网

当前位置: 主页 > 沙龙365 >

(沙龙365) onCreateView中设置RecyclerView的点击事件设

时间:2017-07-18 03:25来源:未知 作者:admin 点击:
public class ListRefreshFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { private SwipeRefreshLayout swipeRefreshLayout; private RecyclerView mRecyclerView; private MyAdapter mAdapter; @Nullable @Override public Vi
public class ListRefreshFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
        
            private SwipeRefreshLayout swipeRefreshLayout;
            private RecyclerView mRecyclerView;
            private MyAdapter mAdapter;
    
            @Nullable
            @Override
            public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
                View view = inflater.inflate(R.layout.fragment_swipelay, container, false);
                swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
                swipeRefreshLayout.setOnRefreshListener(this);
                swipeRefreshLayout.setColorSchemeResources(
                        android.R.color.holo_blue_bright,
                        android.R.color.holo_green_light,
                        android.R.color.holo_orange_light,
                        android.R.color.holo_red_light);
                mRecyclerView = (RecyclerView) view.findViewById(R.id.rv);
                mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
                mRecyclerView.setAdapter(new MyAdapter(getData()));  
                mAdapter.setOnItemClickListener(new MyAdapter.OnItemClickListener(){
                    @Override
                    public void onItemClick(View view, int position) {
                        Toast.makeText(getActivity(), "click "   getData().get(position), Toast.LENGTH_SHORT).show();
                    }
                });
        
                mAdapter.setOnItemLongClickListener(new MyAdapter.OnItemLongClickListener() {
                    @Override
                    public void onItemLongClick(View view, int position) {
                        Toast.makeText(getActivity(),"long click "  getData().get(position),Toast.LENGTH_SHORT).show();
                    }
                });
        return view;
       }
        
            @Override
            public void onRefresh() {...}, 3000);}
            public List
      
      (责任编辑:admin)
织梦二维码生成器
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
推荐内容