Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
修复Android中跳跃的PulltorefreshView列表_Android_Listview_Android Layout_Android Listview_Android Custom View - Fatal编程技术网

修复Android中跳跃的PulltorefreshView列表

修复Android中跳跃的PulltorefreshView列表,android,listview,android-layout,android-listview,android-custom-view,Android,Listview,Android Layout,Android Listview,Android Custom View,我正在android上开发聊天应用程序。我在应用程序中使用拉刷新功能的代码。我的问题是,当我单击EditText编写消息时,出现软键BAORD,如果pulltoRefresh列表有1或2个元素,列表会向上滚动到顶部,但如果pulltoRefresh列表有足够的项覆盖整个屏幕,则列表会正常工作(它不会向上滚动到顶部。) 以下是我的代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout

我正在android上开发聊天应用程序。我在应用程序中使用拉刷新功能的代码。我的问题是,当我单击EditText编写消息时,出现软键BAORD,如果pulltoRefresh列表有1或2个元素,列表会向上滚动到顶部,但如果pulltoRefresh列表有足够的项覆盖整个屏幕,则列表会正常工作(它不会向上滚动到顶部。)

以下是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
                                       xmlns:android="http://schemas.android.com/apk/res/android"
                                       android:id="@+id/parent"
                                       android:layout_width="fill_parent"
                                       android:layout_height="fill_parent"
                                       android:background="@color/white"
                                       android:orientation="vertical">


   <LinearLayout android:id="@+id/buttonsFrame" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="6dp" android:background="@drawable/routecover_bg">

       <LinearLayout android:id="@+id/messages_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical|center" android:padding="2dp">
                <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_headermessageselect" android:id="@+id/msg_icon"/>  
       </LinearLayout>

       <LinearLayout android:id="@+id/locations_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical|center"  android:padding="2dp">
                <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_headerlocation" android:id="@+id/location_icon"/>  
       </LinearLayout>

       <LinearLayout android:id="@+id/members_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical|center"  android:padding="2dp">
                <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_headermember" android:id="@+id/member_icon"/>  
       </LinearLayout>

    </LinearLayout>


            <ChatWindow                           android:id="@+id/messages_window"
                                                  android:layout_width="fill_parent"
                                                  android:layout_weight="1"
                                                  android:layout_height="fill_parent"/>
聊天室窗口布局代码:

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

  <LinearLayout android:layout_width="fill_parent" 
                android:layout_height="0dip"  
                android:layout_weight="1"
                android:orientation="vertical">    

 <PullToRefreshListView
           android:id="@+id/chatlist"  
           android:dividerHeight="2dp"
           android:layout_weight="1"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:smoothScrollbar="true"
           android:cacheColorHint="#00000000"
           android:transcriptMode="alwaysScroll" 
           android:stackFromBottom="true"
           android:scrollbars="none" 
           android:divider="@color/white"/>

</LinearLayout> 

<LinearLayout       xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/parentcontainer"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:background="@color/bg_menubar">


    <EditText   android:id="@+id/name" android:hint="Compose"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:layout_weight="1"
                android:scrollbars="vertical"
                android:paddingTop="6dp" 
                android:paddingBottom="6dp" 
                android:paddingLeft="10dp" 
                android:paddingRight="10dp" 
                android:maxLines="3"
                android:layout_marginRight="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp"
                />

    <ImageButton android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:id="@+id/send_button"
                 android:background="@drawable/bg_sendbutton"
                 android:layout_marginRight="8dp"/>

  </LinearLayout>

    </LinearLayout>
 </LinearLayout>


仅供我参考,你是说你想从屏幕底部而不是顶部添加列表项?我建议Chris Banes Pull刷新,它已经完成了很多选择,现在非常流畅-仅供我参考,你是说你想从屏幕底部添加列表项顶部的广告正确吗?我建议克里斯·贝恩斯刷新一下,它已经做了很多选择,现在非常顺利-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical" >

  <LinearLayout android:layout_width="fill_parent" 
                android:layout_height="0dip"  
                android:layout_weight="1"
                android:orientation="vertical">    

 <PullToRefreshListView
           android:id="@+id/chatlist"  
           android:dividerHeight="2dp"
           android:layout_weight="1"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           android:smoothScrollbar="true"
           android:cacheColorHint="#00000000"
           android:transcriptMode="alwaysScroll" 
           android:stackFromBottom="true"
           android:scrollbars="none" 
           android:divider="@color/white"/>

</LinearLayout> 

<LinearLayout       xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/parentcontainer"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:gravity="center_vertical"
                android:background="@color/bg_menubar">


    <EditText   android:id="@+id/name" android:hint="Compose"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:layout_weight="1"
                android:scrollbars="vertical"
                android:paddingTop="6dp" 
                android:paddingBottom="6dp" 
                android:paddingLeft="10dp" 
                android:paddingRight="10dp" 
                android:maxLines="3"
                android:layout_marginRight="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp"
                />

    <ImageButton android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:id="@+id/send_button"
                 android:background="@drawable/bg_sendbutton"
                 android:layout_marginRight="8dp"/>

  </LinearLayout>

    </LinearLayout>
 </LinearLayout>