Comments (5)
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.
Could you please send snipet of your code?
Also, were you able to run the sample code in this repository?
from androidexpandingviewlibrary.
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.
Please need your help sorry for the noob question @diegodobelo
from androidexpandingviewlibrary.
Thanks, alot sir. I really mean it for sparing your precious time and effort to solve my problem!
from androidexpandingviewlibrary.
Related Issues (20)
- Is it possible to make this nice library fully RTL? HOT 3
- How to create another list inside child item HOT 2
- Issues with service
- Couldn't resolve resource HOT 2
- Sub Item not visible HOT 2
- how get data from API (Json) Server?
- List items doesn't expand. HOT 1
- setname from another activity
- Override the item header onClick method
- Subview's textViews don't center horizontally all the time HOT 1
- How to display the another list in the subitems(child) HOT 1
- How to set Icons in every SubItems HOT 1
- How to update the title of the item?
- Expanded by default- problem with indicator
- Can I add 1 more sub category? HOT 2
- Slow rendering large list HOT 1
- Store in Internal Storage
- How to expand one item of an ExpandingList at a time, thus opening a another item would close the previously opened item? HOT 1
- Change layout seperator when item expand HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidexpandingviewlibrary.