Android Expandablelistview - Looking for a Tutorial

Android ExpandableListView - Looking for a tutorial

you can find working example of the expandable list view by following links:

  • ExpandableListView

  • Expandable ListView in ANDROID

  • Android Expandable ListView simple Example in android.

for click on child, you can handle this way.

getExpandableListView().setOnChildClickListener(new OnChildClickListener() {                
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// your code...
}
});

Hope this will help you.
Thanks..

Implementing an expandable listview in tab fragment

1) Call findViewById() on the View returned
findViewById in Fragment

2) Change the first argument in the ExpandableListAdapter from 'this' to 'getActivity()'

My new onCreateView looks like this:

public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.tab_expandable_list, container, false);

// get the listview
expListView = (ExpandableListView) view.findViewById(R.id.lvExp);

// preparing list data
prepareListData();

listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);

// setting list adapter
expListView.setAdapter(listAdapter);

return view;
}

ExpandableListview - How do I close the previous opened item, when another item is clicked?

So you need only one (or zero) expanded group at a time. Right? The following code will close the previously expanded group when you expand another one. Try it.

Here you go

final int[] prevExpandPosition = {-1};
expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
if (prevExpandPosition[0] >= 0 && prevExpandPosition[0] != groupPosition) {
expandableListView.collapseGroup(prevExpandPosition[0]);
}
prevExpandPosition[0] = groupPosition;
}
});

ExpandableListView with Drag and Drop of List Items in Android

Yes sure you can implement Drag and Drop in List View.. Here is the Samples for Drag and Drop in List View.. Drag and Drop Sample.. Download Zip file from this part in the page -(You can find the project here.)



Related Topics



Leave a reply



Submit