Go Back   Android Forums > Android Development > Application Development
Application Development Dev Lounge for the Coder Folks
Gamers - Check out our new sister sites!
Nintendo Wii U!    |    OUYA - $99 Android System!

test: Reply
 
LinkBack Thread Tools
Old April 4th, 2012, 01:47 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Apr 2012
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Question How can I retrieve ListView height and set ListView Items (cells) height depending on ListView Heigh

I have some class LoginActivity.java. In the onCreate method I retrieve ListView:

ListView list = (ListView)findViewById(R.id.snListView);
then:

list.setAdapter(adapter);
In addition there are login.xml layout - there are:

<ListView
android:id="@+id/snListView"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
and sn_row.xml:

<RelativeLayout xmlns:andr..."
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="@drawable/listview_item_background"
androidrientation="horizontal" >
...
At the moment I have cell's height 100dp, I need that cell's height will depend on device, I mean I have here 5 cells showing at login screen in ListView and I need that these 5 rows will fit the ListView (cell's height = ListView's height/5).

xHitman is offline  
Reply With Quote
Sponsors
Old April 4th, 2012, 01:58 PM   #2 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,932
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 465 Times in 288 Posts
Default

There really is no easy way to do this.

In the onCreate method of the ListActivity subclass, you could go through the ListView and recalculate each cell's height based on the current devices screen size. Dong this, however, it would almost be better just to construct the ListView programmatically to begin with, however.
jonbonazza is offline  
Reply With Quote
Reply
Tags
listview, listview in a list item


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:12 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.