public class OneFragment extends Fragment {
public RecyclerView rv;
public Activity act;
public OneAdapter adapter;
public static UserModel usr;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_one, container, false);
// Replace 'android.R.id.list' with the 'id' of your RecyclerView
rv = (RecyclerView) view.findViewById(R.id.recyclerview);
rv.setHasFixedSize(true);
rv.setAdapter(adapter);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
rv.setLayoutManager(llm);
/* FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new JSONDownloader(MainActivity.this,jsonURL, rv).execute();
}
});*/
new JSONDownloader(act,jsonURL, rv,adapter).execute();
// new JSONTask();
rv.addOnItemTouchListener(
new RecyclerItemClickListener(getActivity(), rv ,new RecyclerItemClickListener.OnItemClickListener() {
@Override public void onItemClick(View view, int position) {
// do whatever
usr = adapter.getItem(position);
Context context=view.getContext();
Intent intent = new Intent(context, DetailActivity.class);
context.startActivity(intent);
}
@Override public void onLongItemClick(View view, int position) {
// do whatever
}
})
);
return view;
}
}
Внимание вопрос: Как передать в DetailActivity, с какого фрагмента было выполнено событие, так как имеется несколько фрагментов (табов) OneFragment, TwoFragment и так далее.