我的声明附有我的列表视图的页眉和页脚部分
ListView = (ListView)findViewById(R.id.favoritesList);
View header = View.inflate(this, R.layout.favourites_list_header, null);
View footer = View.inflate(this, R.layout.favourites_list_footer, null);
favouritesListView.addHeaderView(header, null, false);
favouritesListView.addFooterView(footer, null, false);
favouritesListView.setHeaderDividersEnabled(false);
favouritesListView.setFooterDividersEnabled(false);
favouritesListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
这是我的 getView 方法
public View getView(final int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.favouritestext, null);
holder=new ViewHolder();
// my code goes here...
}
}
我的日志猫
10-30 15:06:39.501: ERROR/AndroidRuntime(337): FATAL EXCEPTION: main
10-30 15:06:39.501: ERROR/AndroidRuntime(337): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at java.util.ArrayList.get(ArrayList.java:311)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.widget.ListView.dispatchDraw(ListView.java:2991)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.View.draw(View.java:6846)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.widget.AbsListView.draw(AbsListView.java:2257)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.View.draw(View.java:6743)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.View.draw(View.java:6743)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.View.draw(View.java:6743)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.View.draw(View.java:6743)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.widget.FrameLayout.draw(FrameLayout.java:352)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.View.draw(View.java:6743)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.widget.FrameLayout.draw(FrameLayout.java:352)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.View.draw(View.java:6743)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.widget.FrameLayout.draw(FrameLayout.java:352)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.View.draw(View.java:6743)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.widget.FrameLayout.draw(FrameLayout.java:352)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewRoot.draw(ViewRoot.java:1407)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.os.Handler.dispatchMessage(Handler.java:99)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.os.Looper.loop(Looper.java:123)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at java.lang.reflect.Method.invokeNative(Native Method)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at java.lang.reflect.Method.invoke(Method.java:521)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-30 15:06:39.501: ERROR/AndroidRuntime(337): at dalvik.system.NativeStart.main(Native Method)