ElSajko
ElSajko

Reputation: 1640

Listview, scroll to bottom, weird behaviour with EditText View

I try to scroll listview to the very bottom and it works this way:

listview.setSelection(listview.getCount()-1);

(shame on you Google, basic thing scrollToBottom method, and we had to find other way to achieve it..)

But this doesn't work.. when before using it you type some text.. into EditText View. Funny? Not at all.

Add element to listview -> scrollToBottom -> you are at the very bottom - works
Add element to listview -> type something in EditView -> scrollToBottom - not works
Add element to listview -> type something in EditView -> click anywhere in screen -> scrollToBottom - works!

As we can see problem is strange and weird, I was trying to [anyView].performClick(); but no luck..

Any idea why typing in EditText makes me thinking about Android Dev Team responsible for listview is so lame? And how we can find workaround for this bug.

Thanks for help! :)

Some code:

<ListView
     android:id="@+id/nativeLog"
     android:focusable="false"
     android:focusableInTouchMode="false"
     android:transcriptMode="normal"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:paddingTop="0dp"
     android:paddingBottom="10dp"
     android:clipToPadding="false"
     android:paddingLeft="0dp"
     android:paddingRight="0dp"
     android:cacheColorHint="#00000000"
     android:background="@drawable/gray_bg"
     android:listSelector="@color/transparent"
     android:divider="@null"
     android:dividerHeight="0dp"/>

[...]

<EditText
     android:id="@+id/boxInterfaceEditbox"
     android:scrollHorizontally="false"
     android:inputType="textCapSentences|textLongMessage|textMultiLine|textNoSuggestions"
     android:singleLine="false"
     android:imeOptions="actionSend"
     android:layout_width ="0dp"
     android:layout_weight="1"
     android:layout_height ="wrap_content"
     android:layout_marginLeft="5.5dp"
     android:layout_marginRight="5.5dp"
     android:paddingTop="8.2dp"
     android:paddingBottom="8.2dp"
     android:paddingLeft="8dp"
     android:paddingRight="8dp"
     android:minHeight="@dimen/nav_interface_btn_size"
     android:maxHeight="90dp"
     android:textColor="#bbb"
     android:textSize="15.25dp"
     android:gravity="top"
     android:background="@drawable/nav_boxtextarea"/>

And java

scrollToBottomRunnable = new Runnable() {
     @Override
     public void run() {
         log.setSelection(log.getCount() -1);
     }
};

Upvotes: 1

Views: 184

Answers (1)

bryan c
bryan c

Reputation: 1366

As we tried everything in comments at least we found that should call notifyDatasetChanged() after adding items to list view and after when you switch visibility of listview-footer-child too.

Upvotes: 1

Related Questions