tjerkw / Android-SlideExpandableListView

A better ExpandableListView, with animated expandable views for each list item
Apache License 2.0
1.98k stars 741 forks source link

Null pointer exception while using library in a fragment. #41

Closed satya10x closed 11 years ago

satya10x commented 11 years ago

This is my ListVew xml f_list.xml:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >

    <com.tjerkw.slideexpandable.library.ActionSlideExpandableListView
        android:id="@+id/fListView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" 
        android:listSelector = "@drawable/card_bg" /> 

This is my fragment:

@ContentView(R.layout.f_list) public class Home extends SherlockFragment{

@InjectView(R.id.fListView) ActionSlideExpandableListView linkCardView;
 public View view;
 FAdapter iList;
 public  ArrayList<Link> links = new ArrayList<Link>();
 LinkDataHandler linkReadHandler;
 LinkDataHandler linkWriteHandler;
 private static final String KEY_POSITION="position";
 //ActionSlideExpandableListView listView;

 static Home newInstance(int position) {
        Home frag=new Home();
        Bundle args=new Bundle();

        args.putInt(KEY_POSITION, position);
        frag.setArguments(args);

        return(frag);
      }

 @Override
  public View onCreateView(LayoutInflater inflater, 
                 ViewGroup container, Bundle savedInstanceState){

     TabActivity.currentFragment = "HOME";

     linkReadHandler = new LinkDataHandler(getActivity());
     linkWriteHandler = new LinkDataHandler(getActivity());
     view = inflater.inflate(R.layout.f_list, container, false);

  for(int i = 0;i<5;i++){
      Link link = new Link();
      link.title= "haha";
      link.url = "hoho";
      links.add(link);
     }
    fList = new FAdapter(getActivity(),R.layout.f_list,links, getActivity());
    linkCardView.setAdapter(fList);

    return view;   
  }    

I get a null pointer exception while doing inkCardView.setAdapter(fList);

Any place where I'm going wrong?