질문&답변
쓰레드 질문 입니다.
1시간 걸렸네요. 리스트 어뎁터를 클레스 객체화 해서 사용할수 있게 만들었습니다~~ 1. getLayoutinflater 이거는 혼자 못쓰니까 context를 받아와서 (LayoutInflater)context.GetSystemService(context.Layout_Inflater_Service);이걸로 대체했고. 2. 리스트도 별도로 받아오게 했습니다. 하면서 많이 배웁니다. 감사합니다. 앞으로 이런식으로 클레스 만드는 연습을 많이 해봐야겠어요. package com.first.bestseller; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import java.util.HashMap; import java.util.List; public class listadapterclass extends BaseAdapter { Context context ; List listc ; public listadapterclass(List listc,Context context){ this . listc = listc; this . context = context; } @Override public int getCount() { return listc .size(); } @Override public Object getItem( int position) { return null ; } @Override public long getItemId( int position) { return 0 ; } @Override public View getView( int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService( context . LAYOUT_INFLATER_SERVICE ); convertView = inflater.inflate(R.layout. listcostom , null ); ImageView limg = convertView.findViewById(R.id. limg ); TextView date = convertView.findViewById(R.id. date ); TextView color = convertView.findViewById(R.id. color ); TextView size = convertView.findViewById(R.id. size ); TextView price = convertView.findViewById(R.id. price ); TextView cate = convertView.findViewById(R.id. cate ); TextView name = convertView.findViewById(R.id. name ); TextView lo = convertView.findViewById(R.id. lo ); HashMap map = (HashMap ) listc .get(position); int img = ( int ) map.get( "limg" ); limg.setImageResource(img); date.setText(map.get( "date" ).toString()); color.setText(map.get( "color" ).toString()); size.setText(map.get( "size" ).toString()); price.setText(map.get( "price" ).toString()); cate.setText(map.get( "cate" ).toString()); name.setText(map.get( "name" ).toString()); return convertView; } }
- 좋아요수
- 0
- 댓글수
- 4
- 조회수
- 371





