Giter Site home page Giter Site logo

androiddesignpatterns's People

Contributors

rohitss avatar rohitsurwase avatar rohitwoxi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androiddesignpatterns's Issues

Scrolling RecyclerView Messup the dynamic created textviews

Each row have about 5-10 dynamically created textviews child. During scroll up and down, few of the created textviews disappears.

I'm following exact code with dynamic data. Here is the video link about the issue
https://screencast.com/t/lnJZIiVr79

@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {

    if (holder instanceof ReportViewHolder) {

        ViewCallCardModel callCardModel = callCardReportList.get(holder.getAdapterPosition() - 1);

        ReportViewHolder reportViewHolder = (ReportViewHolder) holder;
        reportViewHolder.tvItemTitle.setText(callCardModel.getItemTitle());
        

        int noOfChildTextViews = ((ReportViewHolder) holder).llItemChoice.getChildCount();
        int noOfChild = callCardModel.getItemChoiceList().size();

        if (noOfChild < noOfChildTextViews) {

            for (int index = noOfChild; index < noOfChildTextViews; index++) {

                TextView currentTextView = (TextView) ((ReportViewHolder) holder).llItemChoice.getChildAt(index);
                currentTextView.setVisibility(View.GONE);
            }
        }

        for (int textViewIndex = 0; textViewIndex < noOfChild; textViewIndex++) {

            ChoiceModel choiceModel = callCardModel.getItemChoiceList().get(textViewIndex);

            TextView currentTextView = (TextView) ((ReportViewHolder) holder).llItemChoice.getChildAt(textViewIndex);
            currentTextView.setText(Html.fromHtml(homeActivity.getString(R.string.ItemChoiceCounter, choiceModel.getChoiceTitle(), choiceModel.getChoiceCounter())));
            currentTextView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Toast.makeText(homeActivity, ((TextView) view).getText().toString(), Toast.LENGTH_SHORT).show();
                }
            });
        }


    }

}

    class ReportViewHolder extends RecyclerView.ViewHolder {

    private TextView tvItemTitle, tvSubItemTitle, tvYes, tvNo;
    private LinearLayout llBooleanChoice, llItemChoice, llSubItemChoice, llSubItems;


    ReportViewHolder(View itemView) {
        super(itemView);


        tvItemTitle = itemView.findViewById(R.id.tvItemTitle);
        tvSubItemTitle = itemView.findViewById(R.id.tvSubItemTitle);

        tvYes = itemView.findViewById(R.id.tvYes);
        tvNo = itemView.findViewById(R.id.tvNo);

        llBooleanChoice = itemView.findViewById(R.id.llBooleanChoices);
        llItemChoice = itemView.findViewById(R.id.llItemChoices);
        llSubItemChoice = itemView.findViewById(R.id.llSubItemChoices);

        llSubItems = itemView.findViewById(R.id.llSubItems);


        //llBooleanChoice.setVisibility(View.GONE);
        llSubItems.setVisibility(View.GONE);

        int maxNoOfChild = 0;
        int maxNoOfSubChild = 0;

        for (int index = 0; index < callCardReportList.size(); index++) {

            int maxSizeTemp = callCardReportList.get(index).getItemChoiceList().size();

            if (maxSizeTemp > maxNoOfChild)
                maxNoOfChild = maxSizeTemp;
            
        }


        for (int index = 0; index < maxNoOfChild; index++) {

            TextView textView = new TextView(itemView.getContext());
            textView.setId(index);
            textView.setTextSize(14.0f);
            textView.setTextColor(Color.BLACK);
            textView.setPadding(10, 20, 10, 20);
            textView.setGravity(Gravity.END);
            textView.setClickable(true);
            textView.setFocusable(true);

            TypedValue typedValue = new TypedValue();
            itemView.getContext().getTheme().resolveAttribute(R.attr.selectableItemBackground, typedValue, true);
            textView.setBackgroundResource(typedValue.resourceId);

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            llItemChoice.addView(textView, layoutParams);
        }


    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.