android - ImageView inflater unreachable code -


i'm trying inflate imageview android says it's unreachable code imageview imageview = (imageview) row.findviewbyid(r.id.imagev); , have remove it. error?

package com.examples.listimage;  import android.os.bundle; import android.app.activity; import android.content.context; import android.content.res.resources; import android.view.layoutinflater; import android.view.menu; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.imageview; import android.widget.listview; import android.widget.textview;  public class listimage extends activity { string[] myimages; string[] descript; int [] images = {r.drawable.ic_launcher, r.drawable.red, r.drawable.strange}; listview list;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_list_image);     resources res = getresources();     myimages = res.getstringarray(r.array.images);     descript = res.getstringarray(r.array.desc);     list = (listview) findviewbyid(r.id.listview1);  } class myadapter extends arrayadapter<string>{ context context; myadapter (context c, string[]images){      super(c, r.layout.example, r.id.textview1,images);     this.context = c;  } @override public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub layoutinflater myinflater = (layoutinflater)     context.getsystemservice(contex.layout_inflater_service);                                   view row = myinflater.inflate(r.layout.example, parent, false); return super.getview(position, convertview, parent);  imageview imageview = (imageview) row.findviewbyid(r.id.imagev); textview textv1 = (textview) row.findviewbyid(r.id.textview1); textview textv2 = (textview) row.findviewbyid(r.id.textview2); }  }} 

xml file:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >  <imageview     android:id="@+id/imagev"     android:layout_width="200dp"     android:layout_height="100dp"     android:layout_alignparentleft="true"     android:layout_alignparenttop="true"     android:layout_marginleft="20dp"     android:layout_margintop="14dp"     android:src="@drawable/ic_launcher" />  <textview     android:id="@+id/textview1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignleft="@+id/imagev"     android:layout_below="@+id/imagev"     android:text="large text"     android:textappearance="?android:attr/textappearancelarge" />  <textview     android:id="@+id/textview2"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignbottom="@+id/textview1"     android:layout_marginleft="15dp"     android:layout_torightof="@+id/textview1"     android:text="medium text"     android:textappearance="?android:attr/textappearancemedium" /> 

the problem returning view method why unreachable

problem:

    return super.getview(position, convertview, parent); //you return here code below unredchable  imageview imageview = (imageview) row.findviewbyid(r.id.imagev); textview textv1 = (textview) row.findviewbyid(r.id.textview1); textview textv2 = (textview) row.findviewbyid(r.id.textview2); 

solution:

add before return method

imageview imageview = (imageview) row.findviewbyid(r.id.imagev);     textview textv1 = (textview) row.findviewbyid(r.id.textview1);     textview textv2 = (textview) row.findviewbyid(r.id.textview2);     return super.getview(position, convertview, parent);  

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -