Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setOnItemClickListener is not working #204

Open
itsmeJithin opened this issue Sep 30, 2020 · 0 comments
Open

setOnItemClickListener is not working #204

itsmeJithin opened this issue Sep 30, 2020 · 0 comments

Comments

@itsmeJithin
Copy link

Main activity contains below code

   ProductRegistrationDetails productRegistrationDetails = new ProductRegistrationDetails();
            productRegistrationDetails.setActiveRegistrationFound(isActiveRegistrationFound);
            productRegistrationDetails.setNumberOfFreebies(numberOfFreebies);
            productRegistrationDetails.setNumberOfRegistrationBasedAdsPerMonth(numberOfRegistrationBasedAdsPerMonth);
            productRegistrationDetails.setRemainingProduct(remainingProduct);
            productRegistrationDetails.setTrialEnabled(isTrialEnabled);
            productRegistrationDetails.setTrialExpired(isTrialExpired);
            productRegistrationDetails.setUpgradedPackageIsUsing(isUpgradedPackageIsUsing);
            ProductRegistrationAdapter adapter = new ProductRegistrationAdapter(context, productRegistrationDetails);

DialogPlus dialogPlus = DialogPlus.newDialog(this)
                    .setAdapter(adapter)
                    .setContentHolder(new ListHolder())
                    .setExpanded(true)
                    .setCancelable(true)
                    .setContentHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
                    .setOnItemClickListener(new OnItemClickListener() {
                        @Override
                        public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
                            CustomSnackBar snackBar = new CustomSnackBar(context, view, "this is test",
                                    Snackbar.LENGTH_LONG, CustomSnackBar.INFO);
                            snackBar.show();
                        }
                    })
                    .create();
            dialogPlus.show();

My Adapter Class

public class ProductRegistrationAdapter extends BaseAdapter {

    private static final String TAG = ProductRegistrationAdapter.class.getSimpleName();
    private Context mContext;


    private ProductRegistrationDetails productRegistrationDetails;

    public ProductRegistrationAdapter(@NonNull Context context, ProductRegistrationDetails details) {
        this.mContext = context;
        productRegistrationDetails = details;
    }

    @Override
    public int getCount() {
        return 1;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        ProductRegistrationAdapter.ViewHolder holder;
        if (view == null) {
            LayoutInflater inflater = (LayoutInflater) mContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = inflater.inflate(R.layout.registration_dialog, viewGroup, false);
            holder = new ProductRegistrationAdapter.ViewHolder();
            holder.registerNow = (Button) view.findViewById(R.id.register_now);
            holder.info = (TextView) view.findViewById(R.id.dialog_info);
            view.setTag(holder);

        } else {
            holder = (ProductRegistrationAdapter.ViewHolder) view.getTag();
        }
        return view;

    }

    private static class ViewHolder {
        TextView info;
        TextView Id;
        Button registerNow;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant