Making child ListView scroll

Hello I am trying to make a terminal type app that is wider than the actual android screen. A listview is great except that I don't want the text to wrap. If the text is wider than the screen I want it to print the full text and then the user can scroll over horizontally if they want to see what was printed off the screen. Just FYI this is for ascii type tables. I have followed this example:

http://nan-technicalblog.blogspot.com/2008/12/android-how-to-use-horizontal-scrolling.html

It works great as far as horizontal text goes it does exactly what I want but I am unable to get the ListView inside the custom LinearLayout to actually scroll veritcally. I have tried passing the Y coordinates from the onScroll method to mListView such as:

mListView.scrollBy(0, distanceY);

but that seems to move the custom LinearLayout window instead of just scrolling the ListView. I can tell that the ListView is not scrolling because the window moves without the vertical scroll bar of the ListView moving. Everything just slides around. Any help would be much appreciated.


Asked by: Freddie165 | Posted: 25-01-2022






Answer 1

Okay this one also took me about a week in my spare time to figure out. I had to change the supplied code for dispatchTouchEvent to this:

 public boolean dispatchTouchEvent(MotionEvent ev){
     mGestureDetector.onTouchEvent(ev);
     mListView.onTouchEvent(ev);
     return true;
 }

Also changed onScroll to return false just for good measure.

Answered by: Walter881 | Posted: 26-02-2022



Similar questions

android - How to pass more than one array to a listview?

I am using a ListView to display items. Currently I am passing a String array of items to it. But I want to pass one more array and display its items along with the items of the first array; that is, somehow having two lines of text. How can I do that?


android - Which is better loading of images for ListView?

I am wondering if which of the two is better in loading images in a listview from web, is it by batch through some number of threads that are running simultaneously or one by one through thread queue? I have noticed (but I don't know if that is really the implementation) from the youtube app that the images are loaded by batch and it is kinda fast. Even for not only loading images but also requesting some data from...


how to list the audio files in a Listview in android

I am new to this android application development. I have a audio files in a particular directory. I want to list the those audio files in a listView. please tell me how to do this activity.


android - display item of listview

I have a list view having several items and it is multichoice list. I want to display the checked item of list view. how i can do this.can anyone help me???


android - Specify view to use when ListView is empty?

I can't find this in the docs - isn't there a way to specify a View to use for a ListView if the adapter is empty? Thanks


How to show a button at the end of an Android ListView

I want to show a button at the end of an Android list view. How can I achieve this? I don't want to stick it to the activity bottom using alignparentbottom="true". Using layout_below does not work for me either. My current XML: <?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android...


java - android listview button control

I have an android listview filled with items. Every item has a button. This is the template of the my listview. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:paddingBottom="6dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="5p...


How to set the Listview item size in android?

I have added an adapter to a list view. For some items, the text is lengthy and the item displays only a portion of the text. How do I fix this? Is there a way to set the size of the list view item?


java - Android Layout with ListView and Buttons

Alright, this specific layout is just annoying me. And can't seem to find a way to have a listView, with a row of buttons at the bottom so that the listview doesn't extend over top of the buttons, and so the buttons are always snapped to the bottom of the screen. Here's what I want: removed dead ImageShack link It seems like it should be so easy, but everything I've tried has failed. Any help? ...


android - Layout :How to get the bottom bar under listview

I hope can get the layout like this: -----Search bar(EditTextview)--- -----Listview(Rows)-------- -----Bottom bar(Contain many buttons)--- Pls give many samples Thanks very much I paste my xml file here.Pls help me check it:


android - How to pass more than one array to a listview?

I am using a ListView to display items. Currently I am passing a String array of items to it. But I want to pass one more array and display its items along with the items of the first array; that is, somehow having two lines of text. How can I do that?


Using a ListView to create a settings screen in Android?

I'm developing my first Android application, and I'd like to create a settings screen. I'd like the screen to have a similar look-and-feel as the native phone-settings screens and the native "create/edit alarm" screen. Thus with different kinds of (statically defined) items vertically stacked with a thin line between them. How do I define such screen? I understand I can use the ListView, but this ...


Android ListView Selector Color

Hi All, I have 2 questions regarding a ListView in Android: How can I get the color of the listview's focused row ? I tried to use the ListView.getSelector() method, which according to its documentation should give me what I'm looking for, but it's giving me a Drawable object which I don't know how to retrieve the color from (if possible...).


android - Which is better loading of images for ListView?

I am wondering if which of the two is better in loading images in a listview from web, is it by batch through some number of threads that are running simultaneously or one by one through thread queue? I have noticed (but I don't know if that is really the implementation) from the youtube app that the images are loaded by batch and it is kinda fast. Even for not only loading images but also requesting some data from...


how to list the audio files in a Listview in android

I am new to this android application development. I have a audio files in a particular directory. I want to list the those audio files in a listView. please tell me how to do this activity.


listview - How to popup list like a spinner without spinner in android?

I have a spinner widget in my activity which lets users pick a list name. Normally, the function of the spinner is to switch between lists but for a couple of instances, I swap out the selection change listener to perform a different function with the same list of options. Once the selection has been made, the old listener is restored and life goes on. This is a bad and buggy arrangement. Instead, I would...


android - display item of listview

I have a list view having several items and it is multichoice list. I want to display the checked item of list view. how i can do this.can anyone help me???


android - Specify view to use when ListView is empty?

I can't find this in the docs - isn't there a way to specify a View to use for a ListView if the adapter is empty? Thanks


listview - Round bottom corners on Android Bitmap?

Hey all, what would be best practice for clipping the bottom borders of a Bitmap? Just manipulate the Bitmap itself or overlay an alpha mask drawable or ...? The whole story: I've a Listview which looks like the iPhone's grouped UITableView style. I would like to display a Bitmap in the last row, but for now the Bitmap overlaps my custom background drawable of the Listview cell. Thx in adva...


java - How do I fill a ListView (in Android) with XML or JSON data?

I read a tutorial, and it uses SQLlite and "SimpleCursorAdapter" to fill the list with items. This is the code the tutorial taught me. private void fillData() { // Get all of the notes from the database and create the item list Cursor c = mDbHelper.fetchAllNotes(); startManagingCursor(c); String[] from = new String[] { NotesDbAdapter.KEY_TITLE }; int[] to = new int[]...






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top