美文网首页
安卓点击listview的footview导致程序崩溃

安卓点击listview的footview导致程序崩溃

作者: Rhett_yu | 来源:发表于2018-08-20 15:36 被阅读0次

需求界面我是固定的20个item,然后直接listView.addFooterView(footView),
点击footview导致程序奔溃,
于是我把 android:enabled="false"加入footview,并且
if (position==20){ return; }
发现部分手机还是会崩溃。
然后看源码

   /
     * @param v The view to add.
     */
    public void addFooterView(View v) {
        addFooterView(v, null, true);
    }

 *
     * @param v The view to add.
     * @param data Data to associate with this view
     * @param isSelectable true if the footer view can be selected
     */
    public void addFooterView(View v, Object data, boolean isSelectable) {}
       

默认的 addFooterView(v, null, true);isSelectable表示footview是否可选择,
默认值为true,表示可选择,
所以直接addFooterView(v, null, false);footview不可选
然后就点击footview再也没有反应了,解决

相关文章

网友评论

      本文标题:安卓点击listview的footview导致程序崩溃

      本文链接:https://www.haomeiwen.com/subject/fylliftx.html