addView(View, LayoutParams) is not supported in AdapterView

来源:2-3 ChooseMessageActivity

小果

2015-11-29 23:34

在打开ChooseMsgActivity时报异常,代码检查过了,基本上按照步骤一步一步来的

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gavin.festval_sms/com.gavin.festval_sms.ChooseMsgActivity}: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView

写回答 关注

2回答

  • Kokutou
    2016-01-27 17:34:52

    AdapterView的子类比如ListView不能在layout中添加子布局,或者在代码中添加子布局。

    请检查activity_choose_msg.xml,应该是把FloatingActionButton放在ListView里面了,要把FloatingActionButton放在ListView外面。

    <ListView
       android:id="@+id/id_lv_msgs"
       android:layout_width="match_parent"
       android:layout_height="match_parent"/>

       <android.support.design.widget.FloatingActionButton
           android:id="@+id/id_fab_toSend"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_alignParentBottom="true"
           android:layout_centerHorizontal="true"
           android:src="@drawable/icon_to_send"
           app:backgroundTint="@color/main_color"
           app:borderWidth="0dp"
           android:layout_marginBottom="@dimen/fab_margin"
           />

    http://img.mukewang.com/56a88f1a0001b6f312800720.jpg


  • Damon_hmz
    2015-12-22 20:31:24

    activity 注册过了吗,检查一下

Android-节日短信送祝福(UI篇)

带领大家实现一个节日短信的群发app以及监听短信的发送状态等

21601 学习 · 55 问题

查看课程

相似问题