I am using a library to select date range, from here
link to that class
I don't know how to use DateRangePicker from fragment and how to use it, to store data.
Here is my code.
Fragment class:
public class LaborerProfile extends Fragment implements DateRangePickerFragment.OnDateRangeSelectedListener {
Switch switch1;
DateRangePickerFragment.OnDateRangeSelectedListener onDateRangeSelectedListener;
TextView Name,Phone_num,Skill,Age,Gender,Village;
RatingBar ratingBar;
String startDate;
String endDate;
public LaborerProfile() {
// Required empty public constructor
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
makeJsonArryReq();
}
#TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView= inflater.inflate(R.layout.laborer_profile, container, false);
switch1 = (Switch) rootView.findViewById(R.id.switch1);
Name = (TextView)rootView.findViewById(R.id.Name_L);
Phone_num = (TextView)rootView.findViewById(R.id.Phone_L);
Skill = (TextView)rootView.findViewById(R.id.Skill_L);
Age = (TextView)rootView.findViewById(R.id.Age_L);
Gender = (TextView)rootView.findViewById(R.id.Gender_L);
Village = (TextView)rootView.findViewById(R.id.Village_L);
ratingBar = (RatingBar) rootView.findViewById(R.id.Rating_L);
switch1.setChecked(true);
switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton compoundButton, boolean bChecked) {
if (bChecked) {
showDateRangePicker();
// /startActivity(new Intent(getActivity(),BusinessActivity.class));
} else {
}
}
});
if (switch1.isChecked()) {
} else {
}
return rootView;
}
public void showDateRangePicker(){
DateRangePickerFragment dateRangePickerFragment= DateRangePickerFragment.newInstance(onDateRangeSelectedListener, false);
dateRangePickerFragment.show(getFragmentManager(),"datePicker");
}
private void makeJsonArryReq() {
// showProgressDialog();
String URL_PROFILE_L="http://192.168.43.160/webservice/Lprofile.php?phone_num_l="+ Const.USER_ID;
Log.d("tirth", URL_PROFILE_L);
JsonArrayRequest req = new JsonArrayRequest(URL_PROFILE_L,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
try {
if (response.length() > 0) {
for (int i = 0; i < response.length(); i++) {
JSONObject jsonObject = response.getJSONObject(i);
if (!jsonObject.isNull("user_name_l")) {
Name.setText(jsonObject.getString("user_name_l"));
}
if (!jsonObject.isNull("phone_num_l")) {
Phone_num.setText(jsonObject.getString("phone_num_l"));
}
if (!jsonObject.isNull("age_l")){
Age.setText(jsonObject.getString("age_l"));
}
if (!jsonObject.isNull("gender_l")){
if(jsonObject.getString("gender_l").equals("1")){
Gender.setText("Male");
}else{
Gender.setText("Female");
}
}
if (!jsonObject.isNull("village_l")){
Village.setText(jsonObject.getString("village_l"));
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
// hideProgressDialog();
}
});
AppController.getInstance().addToRequestQueue(req);
}
#Override
public void onDateRangeSelected(int startDay, int startMonth, int startYear, int endDay, int endMonth, int endYear) {
Log.d("range : ","from: "+startDay+"-"+startMonth+"-"+startYear+" to : "+endDay+"-"+endMonth+"-"+endYear );
}
}
and I haven't changed the fragment provided from GitHub
public class DateRangePickerFragment extends DialogFragment implements View.OnClickListener{
private OnDateRangeSelectedListener onDateRangeSelectedListener;
private TabHost tabHost;
private DatePicker startDatePicker;
private DatePicker endDatePicker;
private Button butSetDateRange;
boolean is24HourMode;
public DateRangePickerFragment() {
// Required empty public constructor
}
public static DateRangePickerFragment newInstance(OnDateRangeSelectedListener callback, boolean is24HourMode) {
DateRangePickerFragment dateRangePickerFragment = new DateRangePickerFragment();
dateRangePickerFragment.initialize(callback, is24HourMode);
return dateRangePickerFragment;
}
public void initialize(OnDateRangeSelectedListener callback,
boolean is24HourMode) {
onDateRangeSelectedListener = callback;
this.is24HourMode = is24HourMode;
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.date_range_picker, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
tabHost = (TabHost) root.findViewById(R.id.tabHost);
butSetDateRange = (Button) root.findViewById(R.id.but_set_time_range);
startDatePicker = (DatePicker) root.findViewById(R.id.start_date_picker);
endDatePicker = (DatePicker) root.findViewById(R.id.end_date_picker);
butSetDateRange.setOnClickListener(this);
tabHost.findViewById(R.id.tabHost);
tabHost.setup();
TabHost.TabSpec startDatePage = tabHost.newTabSpec("start");
startDatePage.setContent(R.id.start_date_group);
startDatePage.setIndicator("Start Date");
TabHost.TabSpec endDatePage = tabHost.newTabSpec("end");
endDatePage.setContent(R.id.end_date_group);
endDatePage.setIndicator("End Date");
tabHost.addTab(startDatePage);
tabHost.addTab(endDatePage);
return root;
}
#Override
public void onStart() {
super.onStart();
if (getDialog() == null)
return;
getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
}
public void setOnDateRangeSelectedListener(OnDateRangeSelectedListener callback) {
this.onDateRangeSelectedListener = callback;
}
#Override
public void onClick(View v) {
dismiss();
onDateRangeSelectedListener.onDateRangeSelected(startDatePicker.getDayOfMonth(),startDatePicker.getMonth(),startDatePicker.getYear(),
endDatePicker.getDayOfMonth(),endDatePicker.getMonth(),endDatePicker.getYear());
}
public interface OnDateRangeSelectedListener {
void onDateRangeSelected(int startDay, int startMonth, int startYear, int endDay, int endMonth, int endYear);
}
}
Related
I am sending Request on fragment to receive Store Item data from Server which contains urls of images like below
public class StoreFragment extends BaseFragment<FragmentStoreBinding, StoreViewModel> implements StoreNavigator {
#Inject
StoreViewModel viewModel;
#Inject
StoreAdapter storeAdapter;
#Inject
StoreVO storeVO;
public static final String TAG = StoreFragment.class.getSimpleName();
private FragmentStoreBinding binding;
public static StoreFragment newInstance() {
Bundle args = new Bundle();
StoreFragment fragment = new StoreFragment();
fragment.setArguments(args);
return fragment;
}
public static StoreFragment newInstance(StoreVO storeVO) {
Bundle args = new Bundle();
StoreFragment fragment = new StoreFragment();
args.putString(INTENT_EXTRA_STOREVO, new Gson().toJson(storeVO)); //put string, int, etc in bundle with a key value
fragment.setArguments(args);
return fragment;
}
#Override
public int getBindingVariable() {
return BR.viewModel;
}
#Override
public int getLayoutId() {
return R.layout.fragment_store;
}
#Override
public StoreViewModel getViewModel() {
return viewModel;
}
#Override
public void goBack() {
getBaseActivity().onFragmentDetached(TAG);
}
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewModel.setNavigator(this);
storeAdapter.setStoreFragment(this);
}
#Override
public void onStart() {
super.onStart();
}
#Override
public void onResume(){
super.onResume();
}
#Override
public void onViewCreated(#NonNull View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
binding = getViewDataBinding();
if (getArguments().containsKey(INTENT_EXTRA_STOREVO)) {
storeVO = new Gson().fromJson(getArguments().getString(INTENT_EXTRA_STOREVO), StoreVO.class);
}
initView();
}
#Override
public void onPrefClicked(String prefSn, boolean sendRequest) {
storeVO.setPrefSn(prefSn);
storeVO.setSearchKeyCode1(prefSn);
switch (prefSn) {
case EAT_PREF_SN:
binding.eatCb.setChecked(true);
break;
case DRINK_PREF_SN:
binding.drinkCb.setChecked(true);
break;
case PLAY_PREF_SN:
binding.playCb.setChecked(true);
break;
case WATCH_PREF_SN:
binding.watchCb.setChecked(true);
break;
case WALK_PREF_SN:
binding.walkCb.setChecked(true);
break;
default:
binding.allCb.setChecked(true);
}
if(sendRequest){
//initStoreView();
viewModel.requestStoreList(storeVO);
}
}
private void initView() {
binding.storeRv.setLayoutManager(new GridLayoutManager(getActivity().getApplicationContext(), 2));
binding.storeRv.setItemAnimator(new DefaultItemAnimator());
binding.storeRv.setAdapter(storeAdapter);
initStoreView();
onPrefClicked(storeVO.getPrefSn(), false);
}
private void initStoreView(){
viewModel.requestStoreList(storeVO);
subscribeStoreListLiveData();
}
private void subscribeStoreListLiveData() {
viewModel.getStoreListLiveData().observe(this, storeList -> {
viewModel.addStoreList(storeList);
if (storeList != null) {
binding.totalCount.setText(String.valueOf(storeList.size()));
}
});
}
}
view model for this fragment is like below
public class StoreViewModel extends BaseViewModel<StoreNavigator> {
public final ObservableList<StoreVO> storeObservableList = new ObservableArrayList<>();
// MutableLiveData는 LifeCycle에 의존하여 메모리관리 등 여러 장점을 지님
private final MutableLiveData<List<StoreVO>> storeListLiveData;
public StoreViewModel(BaseApplication baseApplication) {
super(baseApplication);
storeListLiveData = new MutableLiveData<>();
}
public void requestStoreList(StoreVO storeVO) {
getCompositeDisposable().add(
getRetrofitService().selectStoreInfoList(storeVO)
.subscribeOn(getNetworkHelper().getSchedulerIo())
.observeOn(getNetworkHelper().getSchedulerUi())
.subscribe(storeListLiveData::setValue, throwable -> Dlog.e(throwable.getMessage())));
}
public MutableLiveData<List<StoreVO>> getStoreListLiveData() {
return storeListLiveData;
}
public void addStoreList(List<StoreVO> storeList) {
storeObservableList.clear();
storeObservableList.addAll(storeList);
}
public ObservableList<StoreVO> getStoreObservableList() {
return storeObservableList;
}
public void onFilterClick() {
getNavigator().goToSearchFilterActivity();
}
public void onPrefTypeClicked(String prefSn) {
getNavigator().onPrefClicked(prefSn, true);
}
}
and storeList was attached by adapter like below
public class StoreAdapter extends RecyclerView.Adapter<StoreAdapter.StoreViewHolder> {
private List<StoreVO> storeList;
private StoreFragment storeFragment;
public StoreAdapter() {
this.storeList = new ArrayList<>();
}
#NonNull
#Override
public StoreViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
StoreItemListBinding binding = StoreItemListBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new StoreViewHolder(binding);
}
#Override
public void onBindViewHolder(#NonNull StoreViewHolder holder, int index) {
final int position = index;
holder.bind(storeList.get(index));
holder.itemView.setOnClickListener(v ->
storeFragment.goToPlaceDetailActivity(storeList.get(position)));
}
#Override
public void onViewDetachedFromWindow(#NonNull StoreViewHolder holder) {
holder.viewDetached();
super.onViewDetachedFromWindow(holder);
}
#Override
public int getItemCount() {
return storeList.size();
}
// Override for duplicated bugs
#Override
public long getItemId(int position) {
return super.getItemId(position);
}
// Override for duplicated bugs
#Override
public int getItemViewType(int position) {
return super.getItemViewType(position);
}
public List<StoreVO> getStoreList() {
return storeList;
}
public void setStoreList(List<StoreVO> storeList) {
this.storeList = storeList;
}
public void clearItems() {
storeList.clear();
}
public void addItems(List<StoreVO> storeList) {
this.storeList.addAll(storeList);
notifyDataSetChanged();
}
public StoreFragment getStoreFragment() {
return storeFragment;
}
public void setStoreFragment(StoreFragment storeFragment) {
this.storeFragment = storeFragment;
}
class StoreViewHolder extends RecyclerView.ViewHolder {
private StoreItemListBinding binding;
private ArrayList<String> urlList;
StoreViewHolder(StoreItemListBinding binding) {
super(binding.getRoot());
this.urlList = new ArrayList<>();
this.binding = binding;
initImageSlider();
}
public void bind(StoreVO storeVO) {
binding.priceTv.setText(String.valueOf(storeVO.getReprMenuPrice()));
binding.addrTv.setText(storeVO.getAreaDetailNm());
binding.nameTv.setSelected(true);
binding.nameTv.setText(storeVO.getStoreNm());
binding.scoreTv.setText(String.format(Locale.KOREA, "%.1f", storeVO.getStoreScore()));
addImageSlider(storeVO);
}
private void initImageSlider() {
binding.storeSlider.setIndicatorAnimation(IndicatorAnimations.FILL); //set indicator animation by using SliderLayout.Animations. :WORM or THIN_WORM or COLOR or DROP or FILL or NONE or SCALE or SCALE_DOWN or SLIDE and SWAP!!
binding.storeSlider.setScrollTimeInSec(3); //set scroll delay in seconds :
}
private void addImageSlider(StoreVO storeVO) {
generateUrlList(storeVO);
setSliderViews();
}
private void generateUrlList(StoreVO storeVO) {
urlList.clear();
if (storeVO.getStoreImageUrlList().size() == 0) {
String url = CommonUtils.createDefaultImageUrl();
urlList.add(url);
} else {
for (String imageUrl : storeVO.getStoreImageUrlList()) {
String url = CommonUtils.createStoreImageUrl(storeVO.getStoreSn(), imageUrl);
urlList.add(url);
}
}
}
private void setSliderViews() {
binding.storeSlider.clearSliderViews();
for (String url : urlList) {
DefaultSliderView sliderView = new DefaultSliderView(binding.getRoot().getContext().getApplicationContext());
sliderView.setImageUrl(url);
sliderView.setImageScaleType(ImageView.ScaleType.CENTER_CROP);
//sliderView.setOnSliderClickListener(view -> Dlog.e(url));
//at last add this view in your layout :
binding.storeSlider.addSliderView(sliderView);
}
}
private void viewDetached() {
urlList.clear();
binding.storeSlider.clearSliderViews();
}
}
}
After storeList updated, Text on items of Recylerview was changed but ImageSlider on item was not changed.
I checked that viewDetached() on StoreViewHolder was called but images remaind on previous store item
i was using image sliders in github: https://github.com/smarteist/android-image-slider
what should i do to updated images for imagesliders on recycler-view items???
To simplify my question,
i was using RecyclerView to show items which contains image slider. That image slider load images through URL. After receive new itemList(storeList) from server, itemList(storeList) for RecylerView and URLs in Item(Store) for ImageSlider was changed but not updated on ImageSlider.
Through debugging, i checked that new UrlList was generated and setSliderViews was called but remains previous image
How do i fix my code to update Images on RecylerView's items?
I have an application project for news media using java programming, I
want to display images for categories from drawable into recylerview
that are based on json-api, is there any one who can help me?
How I do for load image from drawable and combine it with data from json-api into RecylerView can anyone provide specific code here
this is my AdapterCategory.java
public class AdapterCategory extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<Category> items = new ArrayList<>();
private Context ctx;
private OnItemClickListener mOnItemClickListener;
private int c;
public interface OnItemClickListener {
void onItemClick(View view, Category obj, int position);
}
public void setOnItemClickListener(final OnItemClickListener mItemClickListener) {
this.mOnItemClickListener = mItemClickListener;
}
// Provide a suitable constructor (depends on the kind of dataset)
public AdapterCategory(Context context, List<Category> items) {
this.items = items;
ctx = context;
}
public class ViewHolder extends RecyclerView.ViewHolder {
// each data item is just a string in this case
public TextView name;
public TextView post_count;
public LinearLayout lyt_parent;
public ImageView imageView;
public ViewHolder(View v) {
super(v);
name = (TextView) v.findViewById(R.id.name);
post_count = (TextView) v.findViewById(R.id.post_count);
imageView = (ImageView)v.findViewById(R.id.image_category);
lyt_parent = (LinearLayout) v.findViewById(R.id.lyt_parent);
//imageView.setImageResource(image_array.length);
}
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// create a new view
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_category, parent, false);
ViewHolder vh = new ViewHolder(v);
return vh;
}
// Replace the contents of a view (invoked by the layout manager)
#Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
if(holder instanceof ViewHolder) {
final Category c = items.get(position);
ViewHolder vItem = (ViewHolder) holder;
vItem.name.setText(Html.fromHtml(c.title));
vItem.post_count.setText(c.post_count + "");
Picasso.with(ctx).load(imageUri).into(vItem.imageView);
vItem.lyt_parent.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(view, c, position);
}
}
});
}
}
public void setListData(List<Category> items){
this.items = items;
notifyDataSetChanged();
}
public void resetListData() {
this.items = new ArrayList<>();
notifyDataSetChanged();
}
// Return the size of your dataset (invoked by the layout manager)
#Override
public int getItemCount() {
return items.size();
}
}
This is my FragmentCategory.java for display data
public class FragmentCategory extends Fragment {
private View root_view, parent_view;
private RecyclerView recyclerView;
private SwipeRefreshLayout swipe_refresh;
private AdapterCategory mAdapter;
private Call<CallbackCategories> callbackCall = null;
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
root_view = inflater.inflate(R.layout.fragment_category, null);
parent_view = getActivity().findViewById(R.id.main_content);
swipe_refresh = (SwipeRefreshLayout) root_view.findViewById(R.id.swipe_refresh_layout_category);
recyclerView = (RecyclerView) root_view.findViewById(R.id.recyclerViewCategory);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(),3));
recyclerView.setHasFixedSize(true);
//set data and list adapter
mAdapter = new AdapterCategory(getActivity(), new ArrayList<Category>());
recyclerView.setAdapter(mAdapter);
// on item list clicked
mAdapter.setOnItemClickListener(new AdapterCategory.OnItemClickListener() {
#Override
public void onItemClick(View v, Category obj, int position) {
ActivityCategoryDetails.navigate((ActivityMain) getActivity(), v.findViewById(R.id.lyt_parent), obj);
}
});
// on swipe list
swipe_refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override
public void onRefresh() {
mAdapter.resetListData();
requestAction();
}
});
requestAction();
return root_view;
}
private void displayApiResult(final List<Category> categories) {
mAdapter.setListData(categories);
swipeProgress(false);
if (categories.size() == 0) {
showNoItemView(true);
}
}
private void requestCategoriesApi() {
API api = RestAdapter.createAPI();
callbackCall = api.getAllCategories();
callbackCall.enqueue(new Callback<CallbackCategories>() {
#Override
public void onResponse(Call<CallbackCategories> call, Response<CallbackCategories> response) {
CallbackCategories resp = response.body();
if (resp != null && resp.status.equals("ok")) {
displayApiResult(resp.categories);
} else {
onFailRequest();
}
}
#Override
public void onFailure(Call<CallbackCategories> call, Throwable t) {
if (!call.isCanceled()) onFailRequest();
}
});
}
private void onFailRequest() {
swipeProgress(false);
if (NetworkCheck.isConnect(getActivity())) {
showFailedView(true, getString(R.string.failed_text));
} else {
showFailedView(true, getString(R.string.no_internet_text));
}
}
private void requestAction() {
showFailedView(false, "");
swipeProgress(true);
showNoItemView(false);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
requestCategoriesApi();
}
}, Constant.DELAY_TIME);
}
#Override
public void onDestroy() {
super.onDestroy();
swipeProgress(false);
if(callbackCall != null && callbackCall.isExecuted()){
callbackCall.cancel();
}
}
private void showFailedView(boolean flag, String message) {
View lyt_failed = (View) root_view.findViewById(R.id.lyt_failed_category);
((TextView) root_view.findViewById(R.id.failed_message)).setText(message);
if (flag) {
recyclerView.setVisibility(View.GONE);
lyt_failed.setVisibility(View.VISIBLE);
} else {
recyclerView.setVisibility(View.VISIBLE);
lyt_failed.setVisibility(View.GONE);
}
((Button) root_view.findViewById(R.id.failed_retry)).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
requestAction();
}
});
}
private void showNoItemView(boolean show) {
View lyt_no_item = (View) root_view.findViewById(R.id.lyt_no_item_category);
((TextView) root_view.findViewById(R.id.no_item_message)).setText(R.string.no_category);
if (show) {
recyclerView.setVisibility(View.GONE);
lyt_no_item.setVisibility(View.VISIBLE);
} else {
recyclerView.setVisibility(View.VISIBLE);
lyt_no_item.setVisibility(View.GONE);
}
}
private void swipeProgress(final boolean show) {
if (!show) {
swipe_refresh.setRefreshing(show);
return;
}
swipe_refresh.post(new Runnable() {
#Override
public void run() {
swipe_refresh.setRefreshing(show);
}
});
}
And this is my ModeCategory.java
public class Category implements Serializable {
public int id = -1;
public String slug = "";
public String type = "";
public String url = "";
public String title = "";
public String title_plain = "";
public String content = "";
public String excerpt = "";
public String date = "";
public String modified = "";
public String description = "";
public int parent = -1;
public int post_count = -1;
public Author author;
public List<Category> categories = new ArrayList<>();
public List<Comment> comments = new ArrayList<>();
public List<Attachment> attachments = new ArrayList<>();
public CategoryRealm getObjectRealm(){
CategoryRealm c = new CategoryRealm();
c.id = id;
c.url = url;
c.slug = slug;
c.title = title;
c.description = description;
c.parent = parent;
c.post_count = post_count;
return c;
}
}
Im building a simple aplication with a recycleView/CardLayout, i followeed this tutorial.
I see many questions answered for the card click, but what i need is to handle diferent actions when the user clicks the title or the user clicks on the image in each card.
This is what i have at the moment:
public class SimiliarPlantsAdapter extends RecyclerView.Adapter<SimiliarPlantsAdapter.PlantViewHolder>{
ArrayList<Plant> plants = new ArrayList<Plant>();
Context context;
public static class PlantViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView plantName;
CheckBox plantCheck;
ImageView plantPhoto;
PlantViewHolder(View itemView) {
super(itemView);
cv = (CardView)itemView.findViewById(R.id.cv);
plantName = (TextView)itemView.findViewById(R.id.plantName);
plantCheck = (CheckBox)itemView.findViewById(R.id.plantCheck);
plantPhoto = (ImageView)itemView.findViewById(R.id.plantPhoto);
}
}
#Override
public PlantViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.similiar_photo_row, viewGroup, false);
PlantViewHolder pvh = new PlantViewHolder(v);
return pvh;
}
#Override
public void onBindViewHolder(PlantViewHolder holder, int position) {
holder.plantName.setText(plants.get(position).getSpecie());
holder.plantCheck.setText("Are you sure this is the plant?");
Log.d("foto",String.valueOf(holder.plantName));
String urlFoto = "http://10.0.2.2:3000/images/" + holder.plantName.getText().toString() + "/Thumbnail.jpg";
Picasso.with(context)
.load(urlFoto)
.resize(250, 250)
.into(holder.plantPhoto);
}
#Override
public int getItemCount() {
return plants.size();
}
public SimiliarPlantsAdapter(ArrayList<Plant> plants,Context context) {
this.plants = plants;
this.context = context;
}
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
}
}
MY Activity
public class SimiliarPhotos extends AppCompatActivity implements IResult {
RecyclerView rv;
LinearLayoutManager llm;
ArrayList<Plant> plants = new ArrayList<Plant>();
SimiliarPlantsAdapter adapter;
VolleyService mVolleyService;
IResult mResultCallback = null;
final String GETREQUEST = "GETCALL";
//login url connection
final String URL = "http://10.0.2.2:3000/plants";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_similiar_photos);
rv = (RecyclerView)findViewById(R.id.rv);
llm = new LinearLayoutManager(this);
llm.setAutoMeasureEnabled(true);
rv.setLayoutManager(llm);
initializeAdapter();
initVolleyCallback();
mVolleyService = new VolleyService(mResultCallback,this);
mVolleyService.getDataVolley(GETREQUEST,URL);
}
#Override
public void notifySuccess(String requestType, JSONObject response) {
Log.d("resposta",response.toString());
}
#Override
public void notifySuccess(String requestType, JSONArray response) {
Log.d("resposta",response.toString());
}
#Override
public void notifyError(String requestType, VolleyError error) {
Log.d("resposta",error.toString());
}
void initVolleyCallback(){
mResultCallback = new IResult() {
#Override
public void notifySuccess(String requestType, JSONObject response) {
}
#Override
public void notifySuccess(String requestType, JSONArray response) {
Plant plant;
Log.d("ENTERED","ENTEREDHERE1");
// iterate over the JSONArray response
for (int i=0; i < response.length(); i++) {
try {
JSONObject object = response.getJSONObject(i); // get the individual object from JSONArray
int id = Integer.parseInt(object.getString("id")); // get the unique identifier from the object
String specie = object.getString("specie"); // get the name of the specie from the object
String description = object.getString("description"); // get the description of the object
plant = new Plant(id,specie,description); // construct the object
Log.d("plant",String.valueOf(plant));
plants.add(plant); // add the object to the arraylist so it can be used on the cardLayout
} catch (JSONException e) {
Log.d("ENTERED",e.toString());
e.printStackTrace();
}
}
adapter.notifyDataSetChanged();
}
#Override
public void notifyError(String requestType, VolleyError error) {
Log.d("resposta",error.toString());
}
};
}
public void initializeAdapter(){
Log.d("plants",String.valueOf(plants.size()));
adapter = new SimiliarPlantsAdapter(plants,SimiliarPhotos.this);
rv.setAdapter(adapter);
}
}
The volley init is the request, not so important for the question, since i get the data correctly
First, you have to add the interface to handle the clicks in your Adapter and add it in your constructor :
public class SimiliarPlantsAdapter extends RecyclerView.Adapter<SimiliarPlantsAdapter.PlantViewHolder>{
private OnItemClickListener listener;
public interface OnItemClickListener {
void onTitleClicked(int position, String title, View clickedview);
void onImageClicked(int position, View clickedview);
}
}
public SimiliarPlantsAdapter(ArrayList<Plant> plants,Context context, OnItemClickListener listener ) {
this.plants = plants;
this.context = context;
this.listener = listener;
}
Now, you have to set these on your onClick method inside your onBindViewHolder:
holder.plantName.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (onItemClickListener != null) {
onItemClickListener.onTitleClicked(holder.getAdapterPosition(), plants.get(position).getSpecie(), view);
}
}
});
holder.plantPhoto.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (onItemClickListener != null) {
onItemClickListener.onItemClicked(holder.getAdapterPosition(), view);
}
}
});
}
}
And finally, implement the interface in your Activity:
public class SimiliarPhotos extends AppCompatActivity implements IResult, SimiliarPlantsAdapter.OnItemClickListener {
#Override
public void onTitleClicked(int position, String title, View clickedView) {
//Handle your title click here
}
#Override
public void onImageClicked(int position, View clickedView) {
//Handle your image click here
}
public void initializeAdapter(){
Log.d("plants",String.valueOf(plants.size()));
adapter = new SimiliarPlantsAdapter(plants,SimiliarPhotos.this, SimilarPhotos.this);
rv.setAdapter(adapter);
}
I'm currently facing a bug in restoring the Position of an ArrayList after orientation cchange to enhance the user experience. I try to store the ArrayList and already made movieData Parcelable. When using a debugger after orientation change savedInstance obviously is not null and contained an int value and presumably the parcelable Array List and I don't really know why this code doesn't work yet.
Fragment Class:
public class MovieGridFragment extends Fragment {
public clickInterfaceHelper clickListener;
private GridView movieGridView;
private int index;
public List<movieData> movieDataList = new ArrayList<>();
public ArrayList<movieData> restoreList;
public MovieGridFragment() {} //empty constructor
#Override
public void onAttach(Context context) {
super.onAttach(context);
}
public void setClickListener(clickInterfaceHelper listener) {
this.clickListener = listener;
}
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null)
index = savedInstanceState.getInt("INDEX");
}
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true);
if(movieDataList.isEmpty() && networkChecker.isNetworkAvailableChecker(getContext())) {
movieDataList = new ArrayList<movieData>();
}
if(!movieDataList.isEmpty() && !networkChecker.isNetworkAvailableChecker(getContext())) {
movieDataList = new ArrayList<movieData>();
}
View rootView = inflater.inflate(R.layout.movie_display_fragment, container, false);
movieGridView = (GridView) rootView.findViewById(R.id.gv_movie_display);
if(savedInstanceState != null && savedInstanceState.containsKey("OLDMOVIEDATA")) {
//index = savedInstanceState.getInt("INDEX");
//movieDataList.addAll(Arrays.asList((movieData[]) savedInstanceState.getSerializable("OLDMOVIEDATA")));
restoreList = savedInstanceState.getParcelableArrayList("OLDMOVIEDATA");
movieAdapter adapter = new movieAdapter(getActivity(),restoreList);
adapter.notifyDataSetChanged();
//movieGridView.setAdapter(adapter);
movieGridView.smoothScrollToPosition(index);
}
else {
movieAdapter adapter = new movieAdapter(getActivity(), movieDataList);
adapter.notifyDataSetChanged();
movieGridView.setAdapter(adapter);
}
movieGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if(clickListener != null)
clickListener.clickOnItem(position);
}
});
return rootView;
}
#Override
public void onSaveInstanceState(Bundle outState) {
//outState.putSerializable("OLDMOVIEDATA",movieData.movieDataArray);
outState.putParcelableArrayList("OLDMOVIEDATA",restoreList);
outState.putInt("INDEX",movieGridView.getFirstVisiblePosition());
super.onSaveInstanceState(outState);
}
}
Adapter:
public class movieAdapter extends ArrayAdapter<movieData> {
public movieAdapter(Context context, List<movieData> movieObject) {
super(context, 0, movieObject);
}
public View getView(int pos, View convertingView, ViewGroup viewGroup) {
movieData movieDatas = getItem(pos);
String url="http://image.tmdb.org/t/p/w185"+movieDatas.getMovieImagePath();
if(convertingView == null)
convertingView = LayoutInflater.from(getContext()).inflate(R.layout.image_display,viewGroup,false);
ImageView imageView = (ImageView) convertingView.findViewById(R.id.iv_movie_image);
Picasso.with(getContext()).load(url.trim()).into(imageView);
return convertingView;
}
}
and the main activity:
public class MainActivity extends AppCompatActivity implements clickInterfaceHelper {
public static String sorterString = null;
public static String urlBase = "https://api.themoviedb.org/3/movie/";
public static String urlFinal = null;
RequestQueue requestQueue;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if(savedInstanceState == null) {
MovieGridFragment fragment = new MovieGridFragment();
fragment.setClickListener(this);
getSupportFragmentManager().beginTransaction()
.add(R.id.activity_container, fragment)
.commit();
movieData.movieDataPosition = 0;
}
if(savedInstanceState != null) {
sorterString = savedInstanceState.getString("SORTER");
}
if(sorterString==null)
sorterString="popular?";
if(sorterString!="favorite" && sorterString!=null) {
if(networkChecker.isNetworkAvailableChecker(this)) {
movieRequest();
}
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu_act, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if(id == R.id.m_popularity_action) {
if(sorterString != "popular?") {
sorterString = "popular?";
if(networkChecker.isNetworkAvailableChecker(this))
movieRequest();
}
return true;
}
if(id == R.id.m_action_voter) {
if(sorterString != "top_rated?") {
sorterString = "top_rated?";
if(networkChecker.isNetworkAvailableChecker(this))
movieRequest();
}
return true;
}
if(id == R.id.m_favorite_btn) {
if(sorterString != "favorite") {
SQLiteOpenHelper helper = new movieDataDbHelper(this);
SQLiteDatabase database = helper.getReadableDatabase();
Cursor cursor= database.query(movieDataContract.contractEntry.TABLE_NAME,
new String[] {
movieDataContract.contractEntry.ID,
movieDataContract.contractEntry.IMG_PATH},null,null,null,null,null);
if(cursor.getCount() == 0) {
Toast.makeText(this, "there are no favorite movies yet!",Toast.LENGTH_SHORT).show();
} else {
sorterString = "favorite";
showFavoriteFragment();
}
database.close();
helper.close();
cursor.close();
}
return true;
}
return super.onOptionsItemSelected(item);
}
public void showFavoriteFragment() {
favoriteMoviesDetailsFragment fragment = new favoriteMoviesDetailsFragment();
try {
getFragmentManager().beginTransaction().replace(R.id.activity_container,fragment).commit();
} catch (Exception e) {
e.printStackTrace();
}
}
#Override
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
outState.putString("SORTER", sorterString);
outState.putInt("POSITION",movieData.movieDataPosition);
super.onSaveInstanceState(outState, outPersistentState);
}
public void movieRequest() {
final MovieGridFragment gridFragment = new MovieGridFragment();
gridFragment.setClickListener(this);
urlFinal = urlBase + sorterString + movieData.apiKey;
urlFinal.trim();
requestQueue = Volley.newRequestQueue(this);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, urlFinal, null, new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
JSONArray array = response.getJSONArray("results");
movieData.movieDataArray = new movieData[array.length()];
for (int i = 0; i < array.length(); i++) {
movieData movie = new movieData();
JSONObject jsonObject = array.getJSONObject(i);
movie.setMovieId(jsonObject.getString("id"));
movie.setMovieImagePath(jsonObject.getString("poster_path"));
movie.setMovieTitle(jsonObject.getString("original_title"));
movie.setMoviePlot(jsonObject.getString("overview"));
movie.setMovieVoting(jsonObject.getString("vote_average"));
movie.setMovieReleaseDate(jsonObject.getString("release_date"));
movieData.movieDataArray[i] = movie;
}
gridFragment.movieDataList = Arrays.asList(movieData.movieDataArray);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.activity_container, gridFragment);
try {
transaction.commitAllowingStateLoss();
} catch (Exception e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.e("volley", String.valueOf(error));
}
}
);
requestQueue.add(jsonObjectRequest);
}
#Override
public void clickOnItem(int id) {
movieData.movieDataPosition = id;
if(movieData.movieDataArray == null) {
movieRequest();
} else {
Intent intent = new Intent(this, detailsActivity.class);
intent.putExtra("FRAGMENT","MOVIE");
startActivity(intent);
}
}
#Override
public void favoriteMovieItem(int movieId) {
movieData.dbPosition = movieId;
Intent intent = new Intent(this,detailsActivity.class);
intent.putExtra("FRAGMENT","favorite");
startActivity(intent);
}
}
You already use the
#Override
public void onSaveInstanceState(Bundle outState) {
//outState.putSerializable("OLDMOVIEDATA",movieData.movieDataArray);
outState.putParcelableArrayList("OLDMOVIEDATA",restoreList);
outState.putInt("INDEX",movieGridView.getFirstVisiblePosition());
super.onSaveInstanceState(outState);
}
Just use it to store the position you need to save. Get the position back using the bundle given in the "onCreateView".
If it does not work, put "setRetainInstance(true)" in the "onCreate" function of your fragment. It will prevent your fragment being destroyed then recreated from nothing during orientation change.
However, I read somewhere that's not the correct way to do so with fragment having UI elements (but i never found anything wrong doing this).
If you want an alternative way not using "setRetainInstance", store (and restore) the position on the activity
public void onSaveInstanceState(Bundle outState)"
function. To do so, create a function "getPosition()" in your fragment, call it in the activity saveInstanceState, and create a function "refresh(int position)" in your fragment (and call it on the restored position value) once the fragment is loaded/recreated in the activity.
This question already has answers here:
RecyclerView onClick
(49 answers)
Closed 7 years ago.
Has anyone using RecyclerView found a way to set an onClickListener to items in the RecyclerView?
this my code:
Pasal_Bab.java
public class Pasal_Bab extends Fragment implements SearchView.OnQueryTextListener {
private RecyclerViewEmptySupport rv;
private List<PasalBabModel> mPBH;
private PasalBabAdapter adapter;
private static ArrayList<PasalBabModel> people;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_pasal, container, false);
rv = (RecyclerViewEmptySupport) view.findViewById(R.id.rv_pasal);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
rv.setLayoutManager(layoutManager);
rv.setEmptyView(view.findViewById(R.id.empty));
rv.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
return view;
}
#Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setHasOptionsMenu(true);
String[] locales = Locale.getISOCountries();
mPBH = new ArrayList<>();
for (String countryCode : locales) {
Locale obj = new Locale("Pasalxyz", countryCode);
mPBH.add(new PasalBabModel(obj.getDisplayCountry(), obj.getISO3Country()));
}
adapter = new PasalBabAdapter(mPBH);
rv.setAdapter(adapter);
}
#Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_main, menu);
final MenuItem item = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
searchView.setOnQueryTextListener(this);
MenuItemCompat.setOnActionExpandListener(item,
new MenuItemCompat.OnActionExpandListener() {
#Override
public boolean onMenuItemActionCollapse(MenuItem item) {
// Do something when collapsed
adapter.setFilter(mPBH);
return true; // Return true to collapse action view
}
#Override
public boolean onMenuItemActionExpand(MenuItem item) {
// Do something when expanded
return true; // Return true to expand action view
}
});
}
#Override
public boolean onQueryTextSubmit(String query) {
return false;
}
#Override
public boolean onQueryTextChange(String newText) {
final List<PasalBabModel> filteredModelList = filter(mPBH, newText);
adapter.animateTo(filteredModelList);
adapter.setFilter(filteredModelList);
rv.scrollToPosition(0);
return false;
}
private List<PasalBabModel> filter(List<PasalBabModel> models, String query) {
query = query.toLowerCase();
final List<PasalBabModel> filteredModelList = new ArrayList<>();
for (PasalBabModel model : models) {
final String text = model.getpasalbab_p().toLowerCase();
if (text.contains(query)) {
filteredModelList.add(model);
}
}
return filteredModelList;
}
}
PasalBabAdapter.java
public class PasalBabAdapter extends RecyclerView.Adapter<PasalBabVH> {
private List<PasalBabModel> mPasalBabModel;
public PasalBabAdapter(List<PasalBabModel> mPasalBabModel) {
this.mPasalBabModel = mPasalBabModel;
}
#Override
public void onBindViewHolder(PasalBabVH PasalBabVH, int i) {
final PasalBabModel model = mPasalBabModel.get(i);
PasalBabVH.bind(model);
}
#Override
public PasalBabVH onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.pasalbab_row, viewGroup, false);
return new PasalBabVH(view);
}
public void setFilter(List<PasalBabModel> PasalBabModels) {
mPasalBabModel = new ArrayList<>();
mPasalBabModel.addAll(PasalBabModels);
notifyDataSetChanged();
}
#Override
public int getItemCount() {
return mPasalBabModel.size();
}
public void animateTo(List<PasalBabModel> models) {
applyAndAnimateRemovals(models);
applyAndAnimateAdditions(models);
applyAndAnimateMovedItems(models);
}
private void applyAndAnimateRemovals(List<PasalBabModel> newModels) {
for (int i = mPasalBabModel.size() - 1; i >= 0; i--) {
final PasalBabModel model = mPasalBabModel.get(i);
if (!newModels.contains(model)) {
removeItem(i);
}
}
}
private void applyAndAnimateAdditions(List<PasalBabModel> newModels) {
for (int i = 0, count = newModels.size(); i < count; i++) {
final PasalBabModel model = newModels.get(i);
if (!mPasalBabModel.contains(model)) {
addItem(i, model);
}
}
}
private void applyAndAnimateMovedItems(List<PasalBabModel> newModels) {
for (int toPosition = newModels.size() - 1; toPosition >= 0; toPosition--) {
final PasalBabModel model = newModels.get(toPosition);
final int fromPosition = mPasalBabModel.indexOf(model);
if (fromPosition >= 0 && fromPosition != toPosition) {
moveItem(fromPosition, toPosition);
}
}
}
public PasalBabModel removeItem(int position) {
final PasalBabModel model = mPasalBabModel.remove(position);
notifyItemRemoved(position);
return model;
}
public void addItem(int position, PasalBabModel model) {
mPasalBabModel.add(position, model);
notifyItemInserted(position);
}
public void moveItem(int fromPosition, int toPosition) {
final PasalBabModel model = mPasalBabModel.remove(fromPosition);
mPasalBabModel.add(toPosition, model);
notifyItemMoved(fromPosition, toPosition);
}
}
PasalBabVH.java
public class PasalBabVH extends RecyclerView.ViewHolder {
public TextView p_TextView;
public TextView b_TextView;
public PasalBabVH(View itemView) {
super(itemView);
p_TextView = (TextView) itemView.findViewById(R.id.uud_pasal);
b_TextView = (TextView) itemView.findViewById(R.id.uud_bab);
}
public void bind(PasalBabModel mx) {
p_TextView.setText(mx.getpasalbab_p());
b_TextView.setText(mx.getpasalbab_b());
}
}
PasalBabModel.java
public class PasalBabModel {
String pasalbab_p;
String pasalbab_b;
public PasalBabModel(String pasalbab_p, String pasalbab_b) {
this.pasalbab_p = pasalbab_p;
this.pasalbab_b = pasalbab_b;
}
public String getpasalbab_p() {
return pasalbab_p;
}
public String getpasalbab_b() {
return pasalbab_b;
}
}
please helpme...i'm a beginner :)
Create the adapter like so:
public class CustomAdapter extends RecyclerView.Adapter<Custom.ViewHolder> {
private List<SomeObject> mDataSet;
public OnItemClickListener mItemClickListener;
private Context mContext;
public CustomAdapter(Context context, List<SomeObject> myDataset, OnItemClickListener mItemClickListener) {
this.mDataSet = myDataset;
this.mItemClickListener = mItemClickListener;
this.mContext = context;
}
public void updateData(List<SomeObject> mDataSet) {
this.mDataSet = mDataSet;
notifyDataSetChanged();
}
public void removeItem(int position) {
mDataSet.remove(position);
notifyItemRemoved(position);
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// create a new view
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
return new ViewHolder(v);
}
#Override
public void onBindViewHolder(final ViewHolder holder, int position) {
// - get element from your dataset at this position
// - replace the contents of the view with that element
final SomeObject obj = mDataSet.get(position);
holder.name.setText(obj.getName());
}
#Override
public int getItemCount() {
return mDataSet.size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
TextView name;
public ViewHolder(View v) {
super(v);
name = (TextView) v.findViewById(R.id.naam);
v.setOnClickListener(this);
v.setOnLongClickListener(this);
}
#Override
public void onClick(View v) {
// If not long clicked, pass last variable as false.
mItemClickListener.onItemClick(v, getLayoutPosition(), false, mDataSet);
}
#Override
public boolean onLongClick(View v) {
// If long clicked, passed last variable as true.
mItemClickListener.onItemClick(v, getLayoutPosition(), true, mDataSet);
return true;
}
}
public interface OnItemClickListener {
void onItemClick(View view, int position, boolean isLongClick, List<SomeObject> mFilteredList);
}
}
And set the adapter like this:
mAdapter = new CustomAdapter(getActivity(), dataSet, new CustomAdapter.OnItemClickListener() {
#Override
public void onItemClick(View v, int position, boolean isLongClick, List<SomeObject> mDataSet) {
if (isLongClick) {
//Long click
SomeObject obj = mDataSet.get(position);
} else {
//Normal click
SomeObject obj = mDataSet.get(position);
}
}
});
Use interfaces to handle onClicks.
Put this in the adapter:
public interface OnItemClickListener {
void onClickItem(View view, int position);
}
public void SetOnItemClickListener(OnItemClickListener mItemClickListener) {
this.mItemClickListener = mItemClickListener;
}
and then in view holder do this:
public class PasalBabVH extends RecyclerView.ViewHolder {
public TextView p_TextView;
public TextView b_TextView;
public PasalBabVH(View itemView) {
super(itemView);
p_TextView = (TextView) itemView.findViewById(R.id.uud_pasal);
b_TextView = (TextView) itemView.findViewById(R.id.uud_bab);
p_TextView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (mItemClickListener != null) {
}
}
});
b_TextView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (mItemClickListener != null) {
}
}
});
}
public void bind(PasalBabModel mx) {
p_TextView.setText(mx.getpasalbab_p());
b_TextView.setText(mx.getpasalbab_b());
}
}
In fragment do this:
adapter.SetOnItemClickListener(new PasalBabAdapter.OnItemClickListener() {
#Override
public void onClickItem(View view, int position) {
}});