I have a subclass of ListView. My only problem is I can’t get it to work (not the listview code, but the code to use the listview. Android won’t inflate it (app crashes). I’m sure there is a simple way to get this to work, but I don’t know how.
PullToRefreshListView list;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.cliplistmain);
context = this;
list = (PullToRefreshListView)findViewById(R.id.clipListMain);
list.setOnItemClickListener(this);
list.setOnScrollListener(this);
list.setOnRefreshListener(new OnRefreshListener(){
@Override
public void onRefresh()
{
ClipStore.getInstance().getClips(SugarLoafContext.currentCamera);
}
});
Button btn = (Button)findViewById(R.id.findclipsbtn);
btn.setOnClickListener(this);
SugarLoafContext.lastView = SugarLoafContext.LAST_VIEW_CLIP_LIST;
}
Here is my xml:
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/clipListMain" >
This is only a part of your layout xml file right, so you do have header and namespace information in your XML.
I guess you get a ClassCastException or similar right? Since you’ve got a
ListViewin your xml but cast it into yourPullToRefreshListViewclass.Your layout xml (i.e.
./res/layout/foo.xml) should be something like