dmitry-zaitsev / ExpandableAdapter

ListAdapter that makes an expandable list from your ListView
16 stars 10 forks source link

Stuck using this librasy #1

Open sourcebits-praveenkumar opened 11 years ago

sourcebits-praveenkumar commented 11 years ago

I have BaseExpandableListAdapter. I wrapped this adapter with the ExpandableAdapter provided by the lib it gives me an error saying " The constructor ExpandableAdapter(FragmentActivity, MYExpandableAdapter, int, int) is undefined".

here is the code i have written : ListAdapter lAdapter = new ExpandableAdapter(getActivity(), adapter, R.id.parent_sub_layout, R.id.child_lay); searchResults.setAdapter(lAdapter);

Can you tell me how i can make things working?

dmitry-zaitsev commented 11 years ago

Make sure that your MYExpandableAdapter implements ListAdapter (or extends any other kind of adapter, for example BaseAdapter... which means the same).

sourcebits-praveenkumar commented 11 years ago

MYExpandableAdapter is extending BaseExpandableListAdapter.Is it fine ?

dmitry-zaitsev commented 11 years ago

@sourcebits-praveenkumar no, it is not. Why do you need expandable list adapter, if you're using this library?

sourcebits-praveenkumar commented 11 years ago

I have an ExpandableListView whose childviews i want to animate.How/What i can do with the library?

sourcebits-praveenkumar commented 11 years ago

Hey can u help understanding the library usage.I really need to have the animation in the childs of expandable list view.

sourcebits-praveenkumar commented 11 years ago

You mean to say i can't use this library with the ExpandableList or ExpandableListAdapter.I need to use normal ListView.But in that case how i can have parent view in the List which can receive clicks and show the child view below that?

dmitry-zaitsev commented 11 years ago

@sourcebits-praveenkumar you're right. Clicks on "toggle" button will be handled by this library. Clicks on expanded view you can handle by yourself as usual. Just set OnClickListener to required views.

sourcebits-praveenkumar commented 11 years ago

Ok thaks ..I ll try and get back to u if any more doubts.

sourcebits-praveenkumar commented 11 years ago

Hey Here is the code for my activity class : @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

    ListView ls = (ListView)findViewById(R.id.listView);
    ArrayList<String> s = new ArrayList<String>();
    s.add("Anshul");
    s.add("ara");
    s.add("Ahul");
    s.add("Aul");
    s.add("Al");
    CustAdapter ca = new CustAdapter(this , s);

    ListAdapter lAdapter = new ExpandableAdapter(this, ca, R.id.parent, R.id.child);
    ls.setAdapter(lAdapter);
}

and here is the Adapter

public class CustAdapter extends BaseAdapter{

Context co;
ArrayList<String > yah;
LayoutInflater inf ;
public CustAdapter(Context con , ArrayList<String> al ) {
this.co =  con;
this.yah = al;
inf = LayoutInflater.from(con);

}
@Override
public int getCount() {
    return yah.size();
}

@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = inf.inflate(R.layout.a, null);
    TextView tv = (TextView)v.findViewById(R.id.name);
    tv.setText(yah.get(position));
    return v;
}

}

what is next ?