Pages

Subscribe:

Labels

Wednesday 28 September 2011

Dynamically change the ListView height - Android

This post is used to change the ListView height. This is done depends on the childviews .
 This Utility.java class is like this


 import android.view.View;
import android.view.ViewGroup;
import android.view.View.MeasureSpec;
import android.widget.ListAdapter;
import android.widget.ListView;

public class Utility {
    public static void setListViewHeightBasedOnChildren(ListView listView) {
        ListAdapter listAdapter = listView.getAdapter();
        if (listAdapter == null) {
            // pre-condition
            return;
        }

        int totalHeight = 0;
        int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST);
        for (int i = 0; i < listAdapter.getCount(); i++) {
            View listItem = listAdapter.getView(i, null, listView);
            listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
            totalHeight += listItem.getMeasuredHeight();
        }

        ViewGroup.LayoutParams params = listView.getLayoutParams();
        params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
        listView.setLayoutParams(params);
        listView.requestLayout();
    }
}



In the main Acticity use this Utility class to change the listview height.

 phraseListView=(ListView)findViewById(R.id.phrase_listview);
 phraseAdapter=new PhraseListAdapter(this);
phraseListView.setAdapter(phraseAdapter);
Utility.setListViewHeightBasedOnChildren(phraseListView);
       

100 comments:

Abarshini said...

Thanks for providing really nice information



Android Training

Unknown said...

Thank you very much!

Unknown said...

ooo guys u rock it

Unknown said...

thank u

Slackneo said...

OMG!!! Thank u!!!!!

Unknown said...

Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..
Android Training in Chennai

isabella said...

LEARN | GET JOB | HAPPY LIFE @ TIS Academy
Thank you so much for sharing. it’s useful for me.
Dot Net Training in Chennai
Android Training in Chennai

Dot Net Training in Chennai


Nandhini said...

Thanks for taking time to share this post.It is really useful.Continue sharing more like this.
Regards,
Android Training in Bangalore

isabella jacob said...


Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
Mobile App development Company
Ios App development Company

Unknown said...

Good information. Thankyou for sharing Android online training

Unknown said...

Thank you for sharing sir/madam. You saved my day.

Unknown said...

Wonderful content Thanks for sharing Android Online Training

soumya said...

Check it once through Android Online Training Bangalore for more information on Android Courses.

Unknown said...

Very Useful information Thank you !!
#TWB_ #Blended #Learning and #Technical #Content #Training is delivered through the high impact high-intensity ILT training combined with the low-intensity sustainable intervention. This allows for thousands of trainees to be trained with the same effectiveness at the same time. TWB_ Blended Learning | Technical Content Training

Unknown said...

Nice blog, check it once through Android Online Training for more information.

soumya said...

Great,Android Online Training

Roland said...

Thank you for sharing. Any more information visit hereAndroid Training institute in Delhi | Android Trainer in Gurgaon

Unknown said...

Android Online course is a good blog
Android Online Training

brninfotech said...
This comment has been removed by the author.
Suresh said...
This comment has been removed by the author.
Anuradha Singhaniya said...

The blog was absolutely fantastic! Lot of great information and helpful.It is amazing and wonderful to visit your site. I have read your blog its very attractive and impressive. I like it your blog.We are provide Android Training institute in Delhi. thanks for sharing this blog..

nivedhitha said...

Thanks for information Hadoop developer training

Unknown said...

amazing information in this blog . Thanks for sharing
Android Training in Delhi | Android Corporate Training Delhi

Inwizards said...

Nice blog. Thanks for sharing such great information.Inwizards Inc is a xamarin Development company offers quality xamarin development services best in web industries. Intrested click here - Xamarin Development Company india

Mahesh said...


Thanks, Learned a lot of new things from your post! Good creation and HATS OFF to the creativity of your mind.
Very interesting and useful blog!
Android Training in Gurgaon


Unknown said...

Awesome Blogs share more information and refer the link

Final Year Bca Projects Chennai | Final Year Mca Projects Chennai.

nettech india said...

Thank you for providing me a such useful information about android course

gowthunan said...

I am commenting to let you know what a terrific experience my daughter enjoyed reading through your web page. She noticed a wide variety of pieces
nebosh course in chennai

Unknown said...

I would like to appreciate your work for good accuracy and got informative knowledge from here... Java Training in Chennai | Python Training in Chennai

Anbarasan14 said...

Thanks for sharing a worthy information. This is really helpful. Keep doing more.

Spoken English Institutes in Bangalore
Spoken English Coaching Classes near me
English Speaking Classes in Bangalore
Spoken English Training Institute in Bangalore
Best Spoken English Coaching in Bangalore
English Speaking Course in Bangalore
English Spoking Coaching in Bangalore

akshaya said...

Excellent Blog!!! Such an interesting blog with clear vision, this will definitely help for beginner to make them update.
data analytics training in bangalore
Data Science Courses in Bangalore
Best Data Science Courses in Bangalore
data analytics courses in bangalore
big data analytics training in bangalore
Data Science Certification Bangalore

cynthiawilliams said...

Your article gives lots of information to me. I really appreciate your efforts admin, continue sharing more like this.
Spring Training in Chennai
Spring Training near me
Spring Hibernate Training in Chennai
Hibernate Training in Chennai
Hibernate Training institute in Chennai
Spring Hibernate Training
Struts Training in Chennai

Unknown said...

Thanks for sharing a worthy information. This is really helpful. Keep doing more.

Softlogicseo said...

Hey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
Matlab Training in Chennai |Matlab Training in Chennai
Advanced Dotnet Training in Chennai |Dotnet Training in Chennai
Advanced Android Training in Chennai |Android Training in Chennai
Advanced CCNA Training in Chennai |CCNA Training in Chennai

vinith said...

This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
machine learning course in bangalore

nowfirstviral said...

Amazing Work

안전토토사이트

daizy mathew said...

very useful blog
python course in chennai

Benish said...

Nice post...Thanks for posting...
Python training in Chennai/
Python training in OMR/
Python training in Velachery/
Python certification training in Chennai/
Python training fees in Chennai/
Python training with placement in Chennai/
Python training in Chennai with Placement/
Python course in Chennai/
Python Certification course in Chennai/
Python online training in Chennai/
Python training in Chennai Quora/
Best Python Training in Chennai/
Best Python training in OMR/
Best Python training in Velachery/
Best Python course in Chennai/


salman said...

go to
go to
go to
go to
go to
go to

easylearn said...


Thanks for sharing,you have done a very good job.Keep it up.The content is very interesting and impressive.If you are looking for any online training visit our site.
Best Big Data Hadoop Online Training

manisha said...

This information you provided in the blog that is really unique I love it!!
Android Training in Delhi
Android Training institute in Delhi

svrtechnologies said...

Thanks for sharing such a great information..Its really nice and informative...

sap fico training
sap fico course

Joyal said...

Effective blog with a lot of information. I just Shared you the link below for Courses .They really provide good level of training and Placement,I just Had Android Classes in this institute , Just Check This Link You can get it more information about the Android course.


Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

riyaz said...

Thank you for your useful information!!!It Really great



Android Training Institute in Chennai | Android Training Institute in anna nagar | Android Training Institute in omr | Android Training Institute in porur | Android Training Institute in tambaram | Android Training Institute in velachery



Anonymous said...

Hey guy's i have got something to share from my research work
Sickrage
Louiz
Foundation

CloudLearn ERP said...

You must have a lot of pride in writing quality content. I'm impressed with the amount of solid information you have written in your article. I hope to read more.
Best Data Science training in Mumbai

Data Science training in Mumbai

nisha said...

Lots of information provided this blog. each and every concept should be very uniquely represented.

Data Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery

Jagna Co Kalani said...

Great Article
Final Year Projects in Python

Python Training in Chennai

FInal Year Project Centers in Chennai

Python Training in Chennai

360digitmg said...

I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts.
360digitmg data science course

Maneesha said...

Actually I read it yesterday but I had some thoughts about it and today I wanted to read it again because it is very well written.
360DigiTMG data science course

Anonymous said...


Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
business analytics course
data analytics course
data science course

Sonu Kabir said...

Thanks for sharing information awesome blog post Online Education Quiz website Gk in Hindi

deiva said...

great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
web designing training in chennai

web designing training in omr

digital marketing training in chennai

digital marketing training in omr

rpa training in chennai

rpa training in omr

tally training in chennai

tally training in omr

Jayalakshmi said...

It is very good and useful for students and developer.Learned a lot of new things from your post Good creation,thanks for give a good information.
data science training in chennai

data science training in tambaram

android training in chennai

android training in tambaram

devops training in chennai

devops training in tambaram

artificial intelligence training in chennai

artificial intelligence training in tambaram

radhika said...

Thanks for your informative article,Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome articl

AWS Training in Chennai | Certification | Online Courses

AWS training in Chennai

AWS Online Training in Chennai

AWS training in Bangalore

AWS training in Hyderabad

AWS training in Coimbatore

AWS training

shiny said...

I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here

angular js training in chennai

angular js training in annanagar

full stack training in chennai

full stack training in annanagar

php training in chennai

php training in annanagar

photoshop training in chennai

photoshop training in annanagar

ek said...

I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
Machine Learning Courses in Pune I really enjoy reading and also appreciate your work.
I have bookmarked your website because this site contains valuable information in it. I am really happy with articles quality and presentation. Thanks a lot for keeping great stuff. I am very much thankful for this site.

ek said...

I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
Machine Learning Courses in Pune I quite like reading an article that can make people think. Also, thanks for allowing for me to comment!

Lavanya said...

Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.salesforce training in chennai

software testing training in chennai

robotic process automation rpa training in chennai

blockchain training in chennai

devops training in chennai

suresh said...

Excellent Blog!!! The blog which you have shared here is more informative, This is really too useful and have more ideas and keep sharing many techniques about DevOps. Thanks for giving a such a wonderful blog.
DevOps Training in Chennai

DevOps Course in Chennai

Ranjith said...

I think this the best blog with the most important information filled in this website
I Got the more and more ideas from this blog Thank You for letting us to know.
pythonTraining in chennai

python Course in chennai

rajmohan1140 said...

Thank you for your efforts in the knowledgeable post. Keep posting.

Java Training in Chennai

Java Course in Chennai

Prashant Baghel said...

Very Nice Article
Thanks for sharing this information. I really appreciate it.

Jio Phone Me Screenshot Kasie Lete Hai
Jio Phone Me Whatsapp Status Kaise Dekhe
Mirzapur Season 2 Web Series Download Amazon Prime , Filmywap, Netflix, Dailymotion
Jio Phone Mein Photo Edit Kaise Kare
Best sensitivity settings for pubg mobile 2021
New south movie 2021 hindi dubbed download filmywap

ram said...

It was wonderfull reading your article. Great writing styleIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder

Ashleel Londa said...

It was wonderfull reading your article. Great writing styleiamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder

Rohit said...

Kim Ravida is a lifestyle and business coach who helps women in business take powerful money actions and make solid, productiveIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder

Thakur98 said...

We are used to the fact that we know only religious and public holidays and celebrate only them.Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder Iamlinkfeeder

Himachali Khabarnama said...

Annabelle loves to write and has been doing so for many years.Backlink Indexer My GPL Store Teckum-All about Knowledge

Maneesha said...

This is a fabulous post I seen because of offer it. It is really what I expected to see trust in future you will continue in sharing such a mind boggling post
data scientist training and placement

Bhuvana said...

Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article…

AWS Training in Hyderabad

Online Helmet & Other Acessories Store said...

Shop for the latest Redmi mobiles from Helmet Don at the best prices in India. Xiaomi smartphones include Mi Series, Mi Note Series, Redmi Series, Pocophone, Mi Max Series, Mi Mix Series, and the Blackshark.
HelmetDon
MI
redmi-phones


Rshop said...

Shop Repair & Buy Mobiles Online At best prices in India only at https://rshop.in/location/shanthi-colony-anna-nagar/

Ramesh Sampangi said...

Good work and good blog. Nice information keep sharing more with us. Thanks you.
Machine Learning Institute in Hyderabad

Oliver said...

If You Own A Forex Account, Vt Market Login Is A Tool That You Need To Add To Your Trading Portfolio.

Michael Miler said...

Are You Looking For A Safe And Reliable Broker? aud-to-usd Is One Of The Most Reputable Brokers In The Industry, But What About Their Platform? Read Our Xm Broker Review To Find Out!

UNIQUE ACADEMY said...

hi thanku so much this infromation
cs executive
freecseetvideolectures/

George said...

Do You Now AximTrade Login Is A Secure, Multi-channel, Multi-factor Authentication System, Enabling Customers To Securely Access Their Accounts To Fund/deposit, Request Withdrawal, Update Or Manage Their Profile And More.

Unknown said...

AximTrade Review Is A Forex And Cfd Broker. It Offers Trading In Currency Pairs, Commodities, Indices, And Shares. It Also Provides A Range Of Tools, And 24/7 Customer Service. Sign Up For AximTrade Login Account Today!

Liam said...

link text

George said...

If You Are Looking For A Reliable Fx Broker, Don't Rush And Read This XM REVIEW Review First. This Is A Serious Warning Against The Broker's Illegal Activities.

Himachal News Network said...

Welcome to CapturedCurrentNews – Latest & Breaking India News 2021
Hello Friends My Name Anthony Morris.latest and breaking news drupepower.com

pragyan said...

az 104 exam questions
scrum master exam questions
dp 900 exam questions

BK-25 said...

Best software training institute in Chennai.
Docker Training institute in Chennai
power bi training in chennai
android training in chennai
ios training in chennai
Xamarin Training in Chennai
msbi training in chennai
Informatica training in chennai

Tecvase said...

I never read an informative blog such as this. I really appreciate your work. keep it up and keep updating.

traininginstitute said...

I see some amazingly important and kept up to length of your strength searching for in your on the site
data science course

Maneesha said...

Wonderful illustrated information. I thank you for that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject!
data science course fee in hyderabad

Oliver said...

Forex Broker USA Best Forex Brokers For Your Forex Trading And Fx. The Profanity Review And Forex Today Reviews The Forex Brokers And Provides The Best Fx Ratings And Reviews.

Maneesha said...

It's a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.
data scientist training in hyderabad

Pranisha said...

Quick up the best offer of AWS DevOps Training in Chennai from Infycle Technologies, Excellent software training in Chennai. A massive place to learn other technical courses like Power BI, Cyber Security, Graphic Design and Animation, Block Security, Java, Oracle, Python, Big data, Azure, Python, Manual and Automation Testing, DevOps, Medical Coding etc., with outstanding training with experienced trainers with a fresh environment with 100+ Live Practical Sessions and Real-Time scenario after the finalisation of the course the trainee will able to get through the interview in top MNC’s with an amazing package for more enquiry approach us on 7504633633, 7502633633

careful Bolger said...

Whatsapp Number Call us Now! 01537587949
outsourcing in Bangladesh
USA pone web iphone repair USA
USA SEX WEB careful
bd sex video B tex
bd sex video sex video
bd sex video freelancing course

aptrongurgaon said...

Android Institute in Gurgaon

Anonymous said...

mmorpg oyunlar
ınstagram takipci satin al
tiktok jeton hilesi
tiktok jeton hilesi
ANTALYA SAC EKİM
instagram takipçi satın al
İnstagram Takipci Satın Al
METİN2 PVP SERVERLAR
instagram takipçi satın al

Anonymous said...

perde modelleri
sms onay
Turkcell Mobil Ödeme Bozdurma
nft nasıl alınır
ankara evden eve nakliyat
TRAFİK SİGORTASI
DEDEKTÖR
web sitesi kurma
ASK ROMANLARİ

Amrutha said...

As a business owner, you must maintain a responsive website design in order to appeal to search engines and internet users. When your potential clients search for your organisation online, you must guarantee that they find a legitimate business platform. Otherwise, you risk losing prospective clients' trust and discouraging them from engaging with your brand.
Make an appointment with the best website development company in vizag immediately to create a web page design that will attract qualified traffic and enhance your conversion rate.
website development company in vizag

SwarnApp said...

Thanks for posting the best information, the blog is very good
best jewellery software jewellery accounting software swarnapp software
Jewellery Management Software

SwarnApp said...

Thanks for posting the best information and the blog is very good.
best jewellery software jewellery accounting software swarnapp software
Jewellery Girvi Software

SwarnApp said...

Thanks for posting the best information, the blog is very good
Jewellery ERP Software Dubai
Jewellery ERP Software Dubai

Thinkerstep said...

Thank you for Sharing best Useful information !!!!
Best Web Development Agency USA
Best Web Development Agency USA

queenarts said...

Useful post thanks for sharing
Sai Satcharitra Pdf

queenarts said...

Useful post
gold price in chennai
today gold rate namakkal

Post a Comment