Custom Listview Layout not reflecting in output android -
i designing custom listview layout , in xml part looks desired output , when run in real device throws error " imageview cannot cast textview"
list_row.xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dip" > <linearlayout android:id="@+id/list_row" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_marginright="5dip" android:background="@drawable/image_bg" android:padding="3dip" > <imageview android:id="@+id/list_image" android:layout_width="70dip" android:layout_height="69dip" android:scaletype="fitxy" android:shadowcolor="#585858" android:shadowdx="0.0" android:shadowdy="0.0" android:shadowradius="20" android:src="@drawable/karthik" /> </linearlayout> <imageview android:id="@+id/imageview02" android:layout_width="15dip" android:layout_height="15dip" android:layout_alignleft="@+id/list_row" android:layout_below="@+id/list_row" android:contentdescription="zodiac icon" android:scaletype="fitxy" android:shadowcolor="#8b4513" android:src="@drawable/rings_icon"/> <textview android:id="@+id/title_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_aligntop="@+id/list_row" android:layout_torightof="@+id/list_row" android:text="karthik.kolanji" android:textcolor="#181818" android:textsize="15dip" android:textstyle="bold" android:typeface="sans" /> <textview android:id="@+id/sub_title_category" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_marginright="5dip" android:gravity="right" android:text="facebook friend" android:textcolor="#10bcc9" android:textsize="12dip" android:textstyle="bold" /> <textview android:id="@+id/textview04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignright="@+id/txtview_turns" android:layout_below="@+id/txtview_turns" android:text=" days left" android:textcolor="#996600" android:textsize="9sp" android:textstyle="bold" /> <textview android:id="@+id/txtview_days_left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignright="@+id/textview04" android:layout_below="@+id/textview04" android:text="36" android:textcolor="#990000" android:textsize="27sp" android:textstyle="normal" /> <textview android:id="@+id/list_image_arrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignright="@+id/sub_title_category" android:layout_below="@+id/title_name" android:text="t u r n s" android:textcolor="#996600" android:textsize="9sp" android:textstyle="bold" /> <textview android:id="@+id/txtview_turns" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/list_image_arrow" android:layout_below="@+id/list_image_arrow" android:text="24" android:textcolor="#990000" android:textsize="27sp" android:textstyle="normal" /> <textview android:id="@+id/txtview_next_bd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/textview01" android:layout_alignbottom="@+id/textview01" android:layout_marginleft="14dp" android:layout_torightof="@+id/textview01" android:text="wednesday" android:textcolor="#cc0000" android:textsize="13sp" android:textstyle="bold" /> <textview android:id="@+id/txtview_type_of_reminder" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/imageview02" android:layout_alignright="@+id/list_row" android:text="(anniversary)" android:textcolor="#787878" android:textsize="10sp" android:textstyle="normal" /> <textview android:id="@+id/textview01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/textview02" android:layout_aligntop="@+id/imageview02" android:text="next birthday on : " android:textcolor="#181818" android:textsize="13sp" android:textstyle="normal" /> <textview android:id="@+id/textview02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/textview04" android:layout_alignbottom="@+id/textview04" android:layout_alignleft="@+id/sub_title_birthdate" android:text="zodiac : " android:textcolor="#181818" android:textsize="13sp" android:textstyle="normal" /> <textview android:id="@+id/txtview_zodiac" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/textview02" android:layout_alignbottom="@+id/textview02" android:layout_torightof="@+id/textview02" android:text="sagittarius" android:textcolor="#cc0000" android:textsize="13sp" android:textstyle="normal" /> <textview android:id="@+id/sub_title_birthdate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textview02" android:layout_alignleft="@+id/sub_title_contact_number" android:text="7th, april 1990" android:textcolor="#181818" android:textsize="13dip" /> <textview android:id="@+id/sub_title_contact_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/sub_title_birthdate" android:layout_alignleft="@+id/title_name" android:text="9594080469" android:textcolor="#181818" android:textsize="13dip" /> <imageview android:id="@+id/imageview01" android:layout_width="15dip" android:layout_height="15dip" android:layout_alignbottom="@+id/list_row" android:layout_alignright="@+id/txtview_next_bd" android:layout_marginright="16dp" android:contentdescription="zodiac icon" android:scaletype="fitxy" android:shadowcolor="#8b4513" android:shadowdx="0.0" android:shadowdy="0.0" android:shadowradius="20" android:src="@drawable/aries"/> </relativelayout>
here's layout image link
here's logcat screen shot
error throwing line :
viewholder=new viewholder(); viewholder.txtdaysremainigvalue=(textview)view.findviewbyid(r.id.txtview_days_left); viewholder.txtturnsage=(textview)view.findviewbyid(r.id.txtview_turns); viewholder.txteventweek=(textview)view.findviewbyid(r.id.txtview_next_bd); viewholder.txtnumber=(textview)view.findviewbyid(r.id.sub_title_contact_number); viewholder.txtbirthday=(textview)view.findviewbyid(r.id.sub_title_birthdate); viewholder.txtzodiac=(textview)view.findviewbyid(r.id.textview02); viewholder.txtzodiacvalue=(textview)view.findviewbyid(r.id.txtview_zodiac); viewholder.txtnextbd=(textview)view.findviewbyid(r.id.textview01); viewholder.txtdayremainig=(textview)view.findviewbyid(r.id.textview04); viewholder.txtturnsagevalue=(textview)view.findviewbyid(r.id.txtview_turns); viewholder.thumbzodiacicon= (imageview) view.findviewbyid(r.id.imageview01); viewholder.thumbeventicon = (imageview) view.findviewbyid(r.id.imageview02); viewholder.thumbcontact = (imageview) view.findviewbyid(r.id.list_image); view.settag(viewholder);
use this.
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dip" > <linearlayout android:id="@+id/list_row" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_marginright="5dip" android:background="@drawable/ic_empty" android:padding="3dip" > <imageview android:id="@+id/list_image" android:layout_width="70dip" android:layout_height="69dip" android:scaletype="fitxy" android:shadowcolor="#585858" android:shadowdx="0.0" android:shadowdy="0.0" android:shadowradius="20" android:src="@drawable/karthik" /> </linearlayout> <imageview android:id="@+id/imageview02" android:layout_width="15dip" android:layout_height="15dip" android:layout_alignleft="@+id/list_row" android:layout_below="@+id/list_row" android:contentdescription="zodiac icon" android:scaletype="fitxy" android:shadowcolor="#8b4513" android:src="@drawable/rings_icon" /> <textview android:id="@+id/title_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_aligntop="@+id/list_row" android:layout_torightof="@+id/list_row" android:text="karthik.kolanji" android:textcolor="#181818" android:textsize="15dip" android:textstyle="bold" android:typeface="sans" /> <textview android:id="@+id/sub_title_category" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_marginright="5dip" android:gravity="right" android:text="facebook friend" android:textcolor="#10bcc9" android:textsize="12dip" android:textstyle="bold" /> <textview android:id="@+id/textview04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignright="@+id/txtview_turns" android:layout_below="@+id/txtview_turns" android:text=" days left" android:textcolor="#996600" android:textsize="9sp" android:textstyle="bold" /> <textview android:id="@+id/txtview_days_left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignright="@+id/textview04" android:layout_below="@+id/textview04" android:text="36" android:textcolor="#990000" android:textsize="27sp" android:textstyle="normal" /> <textview android:id="@+id/list_image_arrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignright="@+id/sub_title_category" android:layout_below="@+id/title_name" android:text="t u r n s" android:textcolor="#996600" android:textsize="9sp" android:textstyle="bold" /> <textview android:id="@+id/txtview_turns" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/list_image_arrow" android:layout_below="@+id/list_image_arrow" android:text="24" android:textcolor="#990000" android:textsize="27sp" android:textstyle="normal" /> <textview android:id="@+id/txtview_next_bd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/textview01" android:layout_alignbottom="@+id/textview01" android:layout_marginleft="14dp" android:layout_torightof="@+id/textview01" android:text="wednesday" android:textcolor="#cc0000" android:textsize="13sp" android:textstyle="bold" /> <textview android:id="@+id/textview01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/textview02" android:layout_aligntop="@+id/imageview02" android:text="next birthday on : " android:textcolor="#181818" android:textsize="13sp" android:textstyle="normal" /> <textview android:id="@+id/textview02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/textview04" android:layout_alignbottom="@+id/textview04" android:layout_alignleft="@+id/sub_title_birthdate" android:text="zodiac : " android:textcolor="#181818" android:textsize="13sp" android:textstyle="normal" /> <textview android:id="@+id/txtview_zodiac" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/textview02" android:layout_alignbottom="@+id/textview02" android:layout_torightof="@+id/textview02" android:text="sagittarius" android:textcolor="#cc0000" android:textsize="13sp" android:textstyle="normal" /> <textview android:id="@+id/sub_title_birthdate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textview02" android:layout_alignleft="@+id/sub_title_contact_number" android:text="7th, april 1990" android:textcolor="#181818" android:textsize="13dip" /> <textview android:id="@+id/sub_title_contact_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/sub_title_birthdate" android:layout_alignleft="@+id/title_name" android:text="9594080469" android:textcolor="#181818" android:textsize="13dip" /> <textview android:id="@+id/txtview_type_of_reminder" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/textview01" android:layout_toleftof="@+id/textview01" android:text="(anniversary)" android:textcolor="#787878" android:textsize="10sp" android:textstyle="normal" /> <imageview android:id="@+id/imageview01" android:layout_width="15dip" android:layout_height="15dip" android:layout_above="@+id/txtview_next_bd" android:layout_toleftof="@+id/textview04" android:contentdescription="zodiac icon" android:scaletype="fitxy" android:shadowcolor="#8b4513" android:shadowdx="0.0" android:shadowdy="0.0" android:shadowradius="20" android:src="@drawable/aries" /> </relativelayout>
Comments
Post a Comment