2012-04-22 3 views
0

안녕하세요. 시간 내 주셔서 감사합니다.동적 목록보기 내부 회 전자

사용자 지정 행을 사용하여 목록보기를 만들려고하는데 모든 행에 회 전자가 포함되어 있습니다. 내가 다음 simpleAdapter 및 listview.setAdapter에 추가하고 이후

ArrayList<HashMap> list = new ArrayList<HashMap>(); 
HashMap row = new HashMap(); 

row.put("Land_Links", c.getString(1)); 
row.put("Land_Rechts", c.getString(2)); 
row.put("Datum", c.getString(11)); 
row.put("Tijd", c.getString(10)); 

list.add(row); 

을 그리고 : 이 같은 데이터 행을 작성하고있다. 모든 것이 완벽합니다. 스피너에 대한 onclicklistener를 채우고 설정하는 방법을 이해할 수 없습니다. 이 문제를 해결하는 방법을 알려주실 수 있습니까?

편집

: 모든 행으로

는 내가 채울 새로운 스피너의 모두에 onclick 리스너를 설정하려면, 2 개 개의 새로운 스피너가 생성됩니다 만들 수 있습니다. 나는 스피너에 채워해야하는 값으로 배열을 만들었습니다.

나는 예외 회 얻기 위 내 예에 추가하여 스피너를 채우는 시도 (R.array.score)

가 될 수도 아니다 이 SimpleAdapter에 의해 바운드됩니다.

내 대상 : 텍스트 뷰가 채워진 루프를 하나 얻으려면 회 전자가 채워지고 onclick 청취자가 회 전자로 설정됩니다.

+0

무엇 BaseAdapter를 확장? 어떻게 onClickListener가 작동합니까? 구체적인 세부 사항을 알려주세요. –

답변

-1

어댑터 (BaseAdapter, SimpleAdapter ...)를 확장해야하며 getView (이 이름은 항상 기본 어댑터가 아닌 baseAdapter와 같은 모든 유형의 어댑터) 메소드에 대해 onClickListener를 회 전자로 설정할 수 있습니다. 여기

당신이 여기 http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/

ArrayAdapter와 BaseAdapter

공용 클래스 FrontPageAdapter의 코드에 대한 정보를 찾을 수는 {

private ArrayList<Item> rssItems; 
private static LayoutInflater inflater = null; 

public FrontPageAdapter(Activity activity, ArrayList<Item> items){ 
    super(); 
    rssItems = items; 
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
} 

public int getCount(){ 
    return rssItems.size(); 
} 

public Object getItem(int position){ 
    return rssItems.get(position); 
} 

public long getItemId(int position){ 
    return getItem(position).hashCode(); 
} 

public View getView(int position, View convertView, ViewGroup parent){ 
    if (convertView == null) 
     convertView = inflater.inflate(R.layout.frontpage_item, null); 

    // Get the item 
    Item ls = (Item)getItem(position); 
    if (ls == null) 
     return convertView; 

    //Set the title 
    String title = ls.getTitle(); 
    if (title == null || title.equals("")){ 
     ((TextView)convertView.findViewById(R.id.FrontPageItemHeader)).setText(""); 
    } 
    else{ 
     ((TextView)convertView.findViewById(R.id.FrontPageItemHeader)).setText(title); 
    } 



    //Obtenemos el contenido. En caso de ser null obtenemos la descripcion 
    // String description = ls.getContent(); 
    String subtitle= ls.getDescription(); 
    if (subtitle == null || subtitle.length() == 0){ 
     ((TextView)convertView.findViewById(R.id.FrontPageItemText)).setVisibility(View.GONE); 
    } 
    else{ 
     ((TextView)convertView.findViewById(R.id.FrontPageItemText)).setText(Html.fromHtml(subtitle)); 
    } 

    // Other views, for example your spinner 




    return convertView; 
} 

} 당신이 필요로하는