Setting height of ListView dynamically in run-time

by patrick » Wed, 21 May 2008 14:11:19 GMT


Sponsored Links
 hi

I want to set the height of a ListView during run-time of my
application. It seems that setPreferredHeight(int) doesn't do this job
and I can't find any similar function.

Did somebody already do something similar?

Thanks,
Patrick
--~--~---------~--~----~------------~-------~--~----~



Setting height of ListView dynamically in run-time

by Mark Murphy » Wed, 21 May 2008 14:32:01 GMT


 


I haven't tried this, but here are two ideas:

1. It's possible you need to call requestLayout() on the ListView (or 
possibly the ListView's parent) after calling setPreferredHeight() to 
affect the change.

2. It's also possible that you really need to adjust the height field of 
the LayoutParams for your ListView (obtained through getLayoutParams()), 
then call requestLayout(). Check out the Layout section of the View 
class documentation to see what I mean:

 http://code.google.com/android/reference/android/view/View.html 

If either of those work, let us know!

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
The Busy Coder's Guide to Android Development -- coming in June 2008!

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Setting height of ListView dynamically in run-time

by patrick » Wed, 21 May 2008 14:56:03 GMT


 Hi Mark,




this is the one that works! Here a small code snippet:

AbsoluteLayout al = (AbsoluteLayout)
findViewById(R.id.attachment_layout);
ViewGroup.LayoutParams params = al.getLayoutParams();
params.height = 400;
al.requestLayout();

where the height is specified in "px"

Thanks!
Patrick
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Could not find AVD file

Hi, I am using eclipse with ADT plugin to develop an Android app, the
problem is I could not find a AVD file in the run configuration ->
Android application->target. I've created a AVD following the steps on
the Android website which is located in the default directory C:
\Documents and Settings\xxx\.android\avd, but it can find the AVD file
in the run configuration -> Android JUnit Test -> target, could you
explain it? thanks

--~--~---------~--~----~------------~-------~--~----~

2. Hardware profiles / requirements

Hi all,

I'm looking for info on what kinds of hardware features are required
by Android.

I realize Android is designed to be as flexible as possible, and
that's great, but:

* Can it live (and be usable) without some kind of 5-way navigation
device?
* Can it live without home and back?
* Can it live without the menu key?
* What keys are required (if any) on the keyboard for it to be
functional?  (e.g. sym, search, alt, ....)

Thanks!
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. Duplicated text when using .append in widgets

4. MapView showing as black screen after upgrade to 1.5

5. why in emulator, "/dev/eac" is connected with the audio?

6. Can I put something into the ScrollView of WebView?

7. Activity execute onDestroy() and onCreate() method when push on keyboard.