Giter Club home page Giter Club logo

Comments (5)

Manabu-GT avatar Manabu-GT commented on June 15, 2024 1

The fix is in v0.1.1 and now published to the maven central.
It should go live within a day.

Thank you for you guys's help.

Manabu

from expandabletextview.

Manabu-GT avatar Manabu-GT commented on June 15, 2024

I didn't originally intend this to be used within a ListView where the view gets recycled.
However, I believe you could try the following method to reset the collapsed state within your ListView.
(I never tested it, so it might not work.)

Reset the ExpandableTextView's height to its original value within your getView() method inside your adapter, then call setText() and requestLayout().

from expandabletextview.

com314159 avatar com314159 commented on June 15, 2024

I also use it in listview, I solved this problem, maybe it have some bugs.

  1. first add two members:

    // when in listview , use this map to save collapsed status
    private SparseArrayCompat mConvertTextCollapsedStatus = new SparseArrayCompat();
    private int mPosition;

  2. add a method:

       public void setConvertText(int position,String text) {
    boolean isCollapsed = mConvertTextCollapsedStatus.get(position, true);
    mPosition = position;
    clearAnimation();
    mCollapsed = isCollapsed;
    if (mButton != null) {
        mButton.setImageDrawable(mCollapsed ? mExpandDrawable : mCollapseDrawable);
    }
    clearAnimation();
    if (mCollapsed) {
        if (mTv!=null){
            mTv.setMaxLines(mMaxCollapsedLines);
        }
    } else {
        if (mTv!=null) {
            mTv.setMaxLines(Integer.MAX_VALUE);
        }
    }
    this.getLayoutParams().height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    setText(text);
    requestLayout();
    

    }

  3. in onClick Method, add

    mCollapsed = !mCollapsed;
    mConvertTextCollapsedStatus.put(mPosition, mCollapsed);
    

I have test it , it works in listview.

I will commit it to github next time

from expandabletextview.

com314159 avatar com314159 commented on June 15, 2024

I have commit it to github, hope it can help you.
https://github.com/com314159/ExpandableTextViewInListView/tree/master

from expandabletextview.

com314159 avatar com314159 commented on June 15, 2024

I have fix some bugs in listview, you can see the commit in the github.
Thank you Manabu-GT

from expandabletextview.

Related Issues (20)

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.