• (2 Pages)
  • +
  • 1
  • 2

How to get started with ExpandableListView

#16 swap0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-November 12

Posted 23 November 2012 - 01:35 PM

View PostEndLessMind, on 02 August 2012 - 03:26 PM, said:

Sure you can :)/>

Just use the OnChildClickListener() :)/>

private OnChildClickListener ExpandList_ItemClicked =  new OnChildClickListener() {

		public boolean onChildClick(ExpandableListView parent, View v,
				int groupPosition, int childPosition, long id) {
			// TODO Auto-generated method stub
			ExpandListChild ch =  ExpListItems.get(groupPosition).getItems().get(childPosition);
			//Your code where
			return false;
		}
		
	};



then use ExpandList.setOnChildClickListener(ExpandList_ItemClicked);



Hi EndLessMind

I inserted this section directed into the end of the onCreate callback method of your example code. Nothing has happened for me. And it seems that your ExpandableListView is unselectable. Is this suppose to happen?
Was This Post Helpful? 0
  • +
  • -

#17 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 193
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Posted 24 November 2012 - 01:19 AM

Then you must be doing something wrong.
I know for a fact that i works, because i use the same approach myself in a app with almost 100k downloads.
Was This Post Helpful? 0
  • +
  • -

#18 swap0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-November 12

Posted 25 November 2012 - 09:32 PM

Could it be OS version specific? I'm using Android 4.0 Emulation. Could that be the problem?
Was This Post Helpful? 0
  • +
  • -

#19 swap0  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-November 12

Posted 25 November 2012 - 09:54 PM

Hi again

I figure out what I did wrong. I forget to apply

ExpandList.setOnChildClickListener(ExpandList_ItemClicked);

into the onCreate method. Everything works now.

I'm still a beginner in creating custom list like this expand list. This really help a lot.
Was This Post Helpful? 0
  • +
  • -

#20 hoai  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-December 12

Posted 04 December 2012 - 02:38 AM

Hello,

I tried to implement the code of expandableListView in the code of SlideMenu but I couldn't figure it out. HELP?!
Was This Post Helpful? 0
  • +
  • -

#21 christus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 20-February 13

Posted 20 February 2013 - 11:26 PM

View PostEndLessMind, on 07 August 2012 - 03:04 PM, said:

The code in the code-tag is to be for it self, just like a void.
The code in the "inline"-section, is to be placed in the same part as where you set the adapter.
In this example, it's in the onCreate-method



Can you please tell how can develope dynamic expandable listview?

Regards
Android developer
Trinay Technology Solutions
www.trinaytech.com
5705750475
Was This Post Helpful? 0
  • +
  • -

#22 hbt272  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-September 10

Posted 13 March 2013 - 03:47 AM

Hi,
I have a question: in two function getChildView and getGroupView you have returned view. Why don't you return the TextView tv?
Please! show me why?
thanks.
Tuna

View PostEndLessMind, on 01 August 2012 - 02:45 PM, said:

Thanks :)/>

The getChildView should look like this
	public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View view,
			ViewGroup parent) {
		ExpandListChild child = (ExpandListChild) getChild(groupPosition, childPosition);
		if (view == null) {
			LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
			view = infalInflater.inflate(R.layout.expandlist_child_item, null);
		}
		TextView tv = (TextView) view.findViewById(R.id.tvChild);
		tv.setText(child.getName().toString());
		tv.setTag(child.getTag());
		return view;
	}


and the getGroupView should look like this
	public View getGroupView(int groupPosition, boolean isLastChild, View view,
			ViewGroup parent) {
		ExpandListGroup group = (ExpandListGroup) getGroup(groupPosition);
		if (view == null) {
			LayoutInflater inf = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
			view = inf.inflate(R.layout.expandlist_group_item, null);
		}
		TextView tv = (TextView) view.findViewById(R.id.tvGroup);
		tv.setText(group.getName());
		// TODO Auto-generated method stub
		return view;
	}

But the only if you are using the xml-layout for the group-item and child-item that's shown in the tutorial :)/>
About the NullPointerExeption, are you initializing the adaper?
adapter = new ExpandListAdapter(MainActivity.this, ExpListItems); 


Hope it helps :)/>

Was This Post Helpful? 0
  • +
  • -

#23 8015resource  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-June 13

Posted 12 June 2013 - 12:14 PM

You my friend, are epic....
Was This Post Helpful? 0
  • +
  • -

#24 Horst2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-July 13

Posted 14 July 2013 - 04:23 AM

Nice thing indeed.

Did you make any plans to enable more hierarchy levels? I would have need for that. Otherwise I'll see what I can do to adapt your code.
Was This Post Helpful? 0
  • +
  • -

#25 hyunikel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-March 14

Posted 15 March 2014 - 04:53 AM

Hi EndLessMind,

I followed your tutorial and it works like charm, so thank you for the code and the effort. However, I've been trying to add a different image to every group view. Can you help me do that?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2