android - Expandable list view only one child is showing -


i have expandable list view passing parent items , child items via arraylist..i can see first parent child..by clicking other items nothing happens

the activity , expandable list view adapter codes given below

	expandablelist = (expandablelistview) findviewbyid(r.id.exlist);  		  		expandablelist.setdividerheight(2);  		expandablelist.setgroupindicator(null);  		expandablelist.setclickable(true);    		setgroupparents();  		setchilddata();    		myexpandableadapter exadapter = new myexpandableadapter(data);  		  		exadapter.setinflater((layoutinflater) getsystemservice(context.layout_inflater_service), this);  		expandablelist.setadapter(exadapter);  //		expandablelist.setonchildclicklistener(this);  		expandablelist.setonchildclicklistener(new onchildclicklistener() {  			  			@override  			public boolean onchildclick(expandablelistview parent, view v,  					int groupposition, int childposition, long id) {  				// todo auto-generated method stub  				return false;  			}  		});

package com.javacodegeeks.android.loginapp;    import java.util.arraylist;    import android.app.activity;  import android.view.layoutinflater;  import android.view.view;  import android.view.view.onclicklistener;  import android.view.viewgroup;  import android.widget.baseexpandablelistadapter;  import android.widget.checkedtextview;  import android.widget.textview;  import android.widget.toast;      public class myexpandableadapter extends baseexpandablelistadapter {    	private activity activity;  	private arraylist<object> childtems;  	private string parent;  	private layoutinflater inflater;  	private arraylist<string> parentitems;  	arraylist<objectmodelclass> data;  	arraylist<arraylist<string>> nodes = new arraylist<arraylist<string>>();    	arraylist<string> childs=new arraylist<string>();  	public myexpandableadapter(arraylist<string> parents, arraylist<object> childern) {  		this.parentitems = parents;  		this.childtems = childern;  	}    	public myexpandableadapter(arraylist<objectmodelclass> data) {  		  		this.data=data;  		  		  	}    	public void setinflater(layoutinflater inflater, activity activity) {  		this.inflater = inflater;  		this.activity = activity;  	}    	  	  	@override  	public view getchildview(int groupposition, final int childposition, boolean islastchild, view convertview, viewgroup parent) {  		  		string child = (string) getchild(groupposition, childposition);  		childviewholder childholder;  		  		if (convertview == null) {  			childholder	=	new childviewholder();  			convertview = inflater.inflate(r.layout.group, null);  			childholder.textview = (textview) convertview.findviewbyid(r.id.title);  			childholder.textprice = (textview) convertview.findviewbyid(r.id.price);  			convertview.settag(childholder);  		}  		else  		{  			childholder	=	(childviewholder) convertview.gettag();  		}  		  		  		childholder.textview.settext(child);  		  		  		  		return convertview;  	}  	  	private static class childviewholder  	{  		textview textview;  		textview textprice;  	}  	@override  	public view getgroupview(int groupposition, boolean isexpanded, view convertview, viewgroup parent) {  		  		if (convertview == null) {  			convertview = inflater.inflate(r.layout.row_ex, null);  		}  		  		((checkedtextview) convertview).settext(data.get(groupposition).gettitle());  		((checkedtextview) convertview).setchecked(isexpanded);  		  		return convertview;  	}    	@override  	public object getchild(int groupposition, int childposition) {  		return data.get(groupposition).getchildren().get(childposition);  	}    	@override  	public long getchildid(int groupposition, int childposition) {  		return 0;  	}    	  	@override  	public int getchildrencount(int groupposition) {  		system.out.println(groupposition);  		return data.get(groupposition).getchildren().size();  	}    	@override  	public object getgroup(int groupposition) {  		return data.get(groupposition);  	}    	@override  	public int getgroupcount() {  		return data.size();  	}        	  	  	    	@override  	public boolean hasstableids() {  		return false;  	}    	@override  	public boolean ischildselectable(int groupposition, int childposition) {  		return false;  	}    	@override  	public long getgroupid(int groupposition) {  		// todo auto-generated method stub  		return 0;  	}    }

change this:

@override public object getchild(int groupposition, int childposition) {     return data.get(groupposition).getchildren().get(childposition); } 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -