Giter Club home page Giter Club logo

Comments (5)

diegodobelo avatar diegodobelo commented on July 20, 2024 3

Like this:

private void configureSubItem(final ExpandingItem item, final View view, final String subTitle) {
        ((TextView) view.findViewById(R.id.sub_title)).setText(subTitle);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String title = ((TextView) item.findViewById(R.id.title)).getText().toString();
                String text = title + " - " + subTitle;
                Toast.makeText(getApplicationContext(),text,Toast.LENGTH_LONG).show();
            }
        });
    }

from androidexpandingviewlibrary.

diegodobelo avatar diegodobelo commented on July 20, 2024

Could you please send snipet of your code?
Also, were you able to run the sample code in this repository?

from androidexpandingviewlibrary.

yourtechcode avatar yourtechcode commented on July 20, 2024

private void createItems() {
addItem("John", new String[]{"House", "Boat", "Candy", "Collection", "Sport", "Ball", "Head"}, R.color.pink, R.drawable.ic_ghost);
addItem("Mary", new String[]{"Dog", "Horse", "Boat"}, R.color.blue, R.drawable.ic_ghost);
addItem("Ana", new String[]{"Cat"}, R.color.purple, R.drawable.ic_ghost);
addItem("Peter", new String[]{"Parrot", "Elephant", "Coffee"}, R.color.yellow, R.drawable.ic_ghost);
addItem("Joseph", new String[]{}, R.color.orange, R.drawable.ic_ghost);
addItem("Paul", new String[]{"Golf", "Football"}, R.color.green, R.drawable.ic_ghost);
addItem("Larry", new String[]{"Ferrari", "Mazda", "Honda", "Toyota", "Fiat"}, R.color.blue, R.drawable.ic_ghost);
addItem("Moe", new String[]{"Beans", "Rice", "Meat"}, R.color.yellow, R.drawable.ic_ghost);
addItem("Bart", new String[]{"Hamburger", "Ice cream", "Candy"}, R.color.purple, R.drawable.ic_ghost);
}

private void addItem(String title, String[] subItems, int colorRes, int iconRes) {
    //Let's create an item with R.layout.expanding_layout
    final ExpandingItem item = mExpandingList.createNewItem(R.layout.expanding_layout);

    //If item creation is successful, let's configure it
    if (item != null) {
        item.setIndicatorColorRes(colorRes);
        item.setIndicatorIconRes(iconRes);
        //It is possible to get any view inside the inflated layout. Let's set the text in the item
        ((TextView) item.findViewById(R.id.title)).setText(title);

        //We can create items in batch.
        item.createSubItems(subItems.length);
        for (int i = 0; i < item.getSubItemsCount(); i++) {
            //Let's get the created sub item by its index
            final View view = item.getSubItemView(i);

            //Let's set some values in
            configureSubItem(item, view, subItems[i]);
        }



    }
}

private void configureSubItem(final ExpandingItem item, final View view, final String subTitle) {
    ((TextView) view.findViewById(R.id.sub_title)).setText(subTitle);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(),subTitle,Toast.LENGTH_LONG).show();
        }
    });
}`

in this code whenever i pressed something from subItem it shows me the toast message of the click subitem for example if i clicked on 'house' it shows me house in toast. how can I do same with title one? i mean whenever i clicked something from subitem then it will show me the title in which the subitem is present. for example if i clicked on 'dog' which is present in title "Mary" then the toast message will show me "Mary"
Thank you for your time and helping me!
@diegodobelo

from androidexpandingviewlibrary.

yourtechcode avatar yourtechcode commented on July 20, 2024

Please need your help sorry for the noob question @diegodobelo

from androidexpandingviewlibrary.

yourtechcode avatar yourtechcode commented on July 20, 2024

Thanks, alot sir. I really mean it for sparing your precious time and effort to solve my problem!

from androidexpandingviewlibrary.

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.