안녕하세요^^ 일요일에도 열심히 하시는 안펍여러분들!

 

너무 수고하시네요..질문이 하나있습니다^^

 

우선 첨부된 파일 한번 봐주세요~ㅠㅠ

 

ListView를 커스텀어댑터를 사용해 구성했는데요..

 

우선 이미지와 text두가지형식으로 만들었구요..

 

ArrayList를 만들어서 .add시켰습니다..

 

그런데 그림파일 처럼 문제점이..마지막에 add된놈만 보이더라구요..

 

그렇다고 다른놈들은 아예 안보이는것도 아닌

 

이미지와 텍스트는 안나오고 선택만 되는 그런상황이 발생합니다.;;

 

아무리 머리를 쥐어짜도 해답이 나오질 않네요 ㅠㅠ 명쾌한 답변을 기다리겠습니다!

 

혹시 필요하실지도 몰라 이쪽부분 java코드와 xml코드를 올려봅니다^^ 그럼모두 건승하세요~

 

 public class Setting extends ListActivity{ 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE); 
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setContentView(R.layout.setting);
        
        ArrayList<Set> s_orders = new ArrayList<Set>();
        
        Set s1 = new Set(R.drawable.btn0, "Setting 1");
        Set s2 = new Set(R.drawable.btn1, "Setting 2");
        Set s3 = new Set(R.drawable.btn3, "Setting 3");       
 s_orders.add(s1);
        s_orders.add(s2);
        s_orders.add(s3);
        s_orders.add(s3);
        
        SettingAdapter s_adapter = new SettingAdapter(this, R.layout.row, s_orders);
        
        setListAdapter(s_adapter);
    }
private class SettingAdapter extends ArrayAdapter<Set>{
     private ArrayList<Set> items;
     
     public SettingAdapter(Context context, 
          int textViewResourceId,
          ArrayList<Set> items){
      super(context, textViewResourceId, items);
      this.items = items;
     }
     
     public View getView(int position, View convertView, ViewGroup parent){
      View v = convertView;
      if(v==null){
       LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       v = vi.inflate(R.layout.row, null);
      }
      Set s = items.get(position);
      if(s != null){
       ImageView iv = (ImageView)findViewById(R.id.icon);
       TextView tv = (TextView)findViewById(R.id.label);
       if(iv != null){iv.setBackgroundResource(s.getImage());}
       if(tv != null){tv.setText(s.getText());}
      }
      return v;
     }
    }
    
    public class Set{
     private int iconId;
     private String textSet;
     
     public Set(int iconId, String textSet){
      this.iconId = iconId;
      this.textSet = textSet;
     }
     public int getImage(){
      return iconId;
     }
     public String getText(){
      return textSet;
     }
    }
}

이쪽은 row.xml(각행)이구요

 <?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:minHeight="62px">
 
 <LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="2.5">
  <ImageView android:layout_gravity="center_vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/icon"></ImageView>
 </LinearLayout>
 <LinearLayout android:id="@+id/linearLayout2" android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="fill_parent">
  <TextView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/label" android:textSize="30px"></TextView>
 </LinearLayout>  
</LinearLayout>


이쪽은 각행들이 출력될 setting.xml입니다.

 

 <?xml version="1.0" encoding="UTF-8"?>
<LinearLayout 
android:orientation = "vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/background">
 <ListView
  android:id="@id/android:list"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" />      
</LinearLayout>

profile