0
ImageView를 부풀리기 위해 노력하고 있지만 안드로이드가 도달 할 수없는 코드라고 말합니다. ImageView imageView = (ImageView) row.findViewById(R.id.imageV);
나는 이것을 제거해야합니다. 오류는 어디에 있습니까?ImageView inflater unreachable code
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 파일 :
<?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" />