android - LazyList set item height -


i using listview lazyadapter , need change item row height, seems little more tricky. here adapter:

public class albumdetailsadapter extends baseadapter {      private activity activity;     private arraylist<songs> data;     private static layoutinflater inflater = null;     private mediaplayer mediaplayer;      public albumdetailsadapter(activity a, arraylist<songs> products) {         activity = a;         mediaplayer = new mediaplayer();         data = products;         inflater = (layoutinflater) activity                 .getsystemservice(context.layout_inflater_service);     }      public int getcount() {         return data.size();     }      public object getitem(int position) {         return position;     }      public long getitemid(int position) {         return position;     }      public view getview(final int position, view convertview, viewgroup parent) {         view vi = convertview;         if (convertview == null)             vi = inflater.inflate(r.layout.songs_items, parent);          textview songnumber = (textview) vi                 .findviewbyid(r.id.songs_item_number);         textview albumtitle = (textview) vi                 .findviewbyid(r.id.songs_item_album_title);         textview singer = (textview) vi                 .findviewbyid(r.id.songs_item_album_singer);         final imageview playsong = (imageview) vi.findviewbyid(r.id.songs_item_play);         imageview downloadsong = (imageview) vi                 .findviewbyid(r.id.songs_item_download);          if (!data.get(position).getsong_mp3()                 .equals("http://nelu.burduja.com/musica/songs_with/")) {             downloadsong.setbackgroundresource(r.drawable.down_yes);             if (!mediaplayer.isplaying()) {                 playsong.setbackgroundresource(r.drawable.play_nr);             }             playsong.setonclicklistener(new onclicklistener() {                 @override                 public void onclick(view v) {                     if (mediaplayer.isplaying()) {                         mediaplayer.release();                         playsong.setbackgroundresource(r.drawable.play_nr);                         mediaplayer=new mediaplayer();                     } else {                         playsong.setbackgroundresource(android.r.drawable.ic_media_pause);                         try {                             mediaplayer.setdatasource(data.get(position)                                     .getsong_mp3());                             final progressdialog bufferingdialog=new progressdialog(activity);                             bufferingdialog.setmessage("buffering ...");                             bufferingdialog.show();                             mediaplayer.prepareasync();                             mediaplayer.setonpreparedlistener(new onpreparedlistener() {                                  @override                                 public void onprepared(mediaplayer arg0) {                                     bufferingdialog.dismiss();                                     mediaplayer.start();                                 }                             });                             mediaplayer.setoncompletionlistener(new oncompletionlistener() {                                  @override                                 public void oncompletion(mediaplayer arg0) {                                     playsong.setbackgroundresource(r.drawable.play_nr);                                     mediaplayer.release();                                 }                             });                           } catch (illegalargumentexception e) {                             // todo auto-generated catch block                             e.printstacktrace();                         } catch (securityexception e) {                             // todo auto-generated catch block                             e.printstacktrace();                         } catch (illegalstateexception e) {                             // todo auto-generated catch block                             e.printstacktrace();                         } catch (ioexception e) {                             // todo auto-generated catch block                             e.printstacktrace();                         }                     }                 }             });         }         imageview youtube = (imageview) vi.findviewbyid(r.id.songs_item_video);         if (data.get(position).getsong_mp4().length() > 0) {             youtube.setbackgroundresource(r.drawable.video_nr);             youtube.setonclicklistener(new onclicklistener() {                  @override                 public void onclick(view v) {                     intent intent = new intent(intent.action_view, uri                             .parse(data.get(position).getsong_mp4()));                     v.getcontext().startactivity(intent);                 }             });         }          albumtitle.settext(data.get(position).getsong_title());         singer.settext(data.get(position).getsong_artist());         songnumber.settext((position + 1) + "");         return vi;     } } 

and songs_item xml file:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="50dp"     android:gravity="center_vertical"     android:background="@drawable/list_item_sel"     android:orientation="horizontal"     android:weightsum="100" >      <textview         android:id="@+id/songs_item_number"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_vertical"         android:layout_weight="10"         android:textcolor="@android:color/white" />      <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:layout_weight="55"         android:gravity="center_horizontal"         android:orientation="vertical" >          <textview             android:id="@+id/songs_item_album_title"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center_vertical"             android:textcolor="@android:color/white"             android:textsize="20sp"             android:textstyle="bold" />          <textview             android:id="@+id/songs_item_album_singer"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center_vertical"             android:textcolor="@android:color/white" />     </linearlayout>          <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_weight="35"         android:gravity="right"         android:orientation="horizontal" >      <imageview         android:id="@+id/songs_item_play"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_vertical"         android:contentdescription="@string/app_name"         android:background="@drawable/play_pr" />      <imageview         android:id="@+id/songs_item_video"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_vertical"         android:contentdescription="@string/app_name"         android:background="@drawable/video_pr"/>      <imageview         android:id="@+id/songs_item_download"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_vertical"         android:contentdescription="@string/app_name"         android:background="@drawable/down_no"/>     </linearlayout> </linearlayout> 

no mater changes make in xml cannot change listview's item height. can tell me how can this. saw have try putting vi = inflater.inflate(r.layout.songs_items, parent); in adapters getview method app crashes , gives me error

04-05 11:02:37.502: e/androidruntime(12776): fatal exception: main 04-05 11:02:37.502: e/androidruntime(12776): java.lang.unsupportedoperationexception: addview(view, layoutparams) not supported in adapterview 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.adapterview.addview(adapterview.java:471) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.layoutinflater.inflate(layoutinflater.java:497) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.layoutinflater.inflate(layoutinflater.java:396) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.layoutinflater.inflate(layoutinflater.java:352) 04-05 11:02:37.502: e/androidruntime(12776):    @ com.outsoucefarm.musicagratis.functions.albumdetailsadapter.getview(albumdetailsadapter.java:55) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.abslistview.obtainview(abslistview.java:2033) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.listview.makeandaddview(listview.java:1781) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.listview.filldown(listview.java:672) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.listview.fillfromtop(listview.java:732) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.listview.layoutchildren(listview.java:1634) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.abslistview.onlayout(abslistview.java:1863) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.view.layout(view.java:11278) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.viewgroup.layout(viewgroup.java:4224) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.relativelayout.onlayout(relativelayout.java:925) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.view.layout(view.java:11278) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.viewgroup.layout(viewgroup.java:4224) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.framelayout.onlayout(framelayout.java:431) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.view.layout(view.java:11278) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.viewgroup.layout(viewgroup.java:4224) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.linearlayout.setchildframe(linearlayout.java:1628) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.linearlayout.layoutvertical(linearlayout.java:1486) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.linearlayout.onlayout(linearlayout.java:1399) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.view.layout(view.java:11278) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.viewgroup.layout(viewgroup.java:4224) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.widget.framelayout.onlayout(framelayout.java:431) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.view.layout(view.java:11278) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.viewgroup.layout(viewgroup.java:4224) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1489) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.view.viewrootimpl.handlemessage(viewrootimpl.java:2442) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.os.handler.dispatchmessage(handler.java:99) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.os.looper.loop(looper.java:137) 04-05 11:02:37.502: e/androidruntime(12776):    @ android.app.activitythread.main(activitythread.java:4440) 04-05 11:02:37.502: e/androidruntime(12776):    @ java.lang.reflect.method.invokenative(native method) 04-05 11:02:37.502: e/androidruntime(12776):    @ java.lang.reflect.method.invoke(method.java:511) 04-05 11:02:37.502: e/androidruntime(12776):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:787) 04-05 11:02:37.502: e/androidruntime(12776):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:554) 04-05 11:02:37.502: e/androidruntime(12776):    @ dalvik.system.nativestart.main(native method) 

so please me solve problem

solved problem. line vi = inflater.inflate(r.layout.songs_items, null); should vi = inflater.inflate(r.layout.songs_items, parent, false);


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -