public class TeamMemberDisplay extends Activity{
String receivedString;
ListView list;
int listingCnt;
String[] customerno ={"My Information","Announcement","Team Member","Online Recruit"};
String[] mobile={"My Information","Announcement","Team Member","Online Recruit"};
String[] knam={"My Information","Announcement","Team Member","Online Recruit"};;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Intent i = getIntent();
receivedString = i.getStringExtra("customerno");
Log.d("MKLog","Team Memeber Display Page start with customerno : " + receivedString);
setContentView(R.layout.teamdisplay);
list = (ListView)findViewById(R.id.lvCustomerList);
listingCnt = 1;
CustomerAdapter ca = new CustomerAdapter(this,R.layout.teamdisplayrow, customerno);
list.setAdapter(ca); //호출 시 getView로 이동..
}
public class CustomerAdapter extends ArrayAdapter{
Activity context;
int pos;
public CustomerAdapter(Context context, int teamDisplayRowResourceId, Object[] list) {
// TODO Auto-generated constructor stub
super(context, teamDisplayRowResourceId,list);
this.context = (Activity) context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) { //getView 클래스...
// TODO Auto-generated method stub
Log.d("MKLog", "setAdapter Called : " + position);
this.pos = position;
Log.d("MKLog", "position : " + position);
LayoutInflater inflator = this.context.getLayoutInflater();
View view=inflator.inflate(R.layout.teamdisplayrow, null);
TextView tvTxtName = (TextView)findViewById(R.id.txtName);
TextView tvTxtCustNo = (TextView)findViewById(R.id.txtCustomerno);
Log.d("MKLog",kname[position]);
if (customerno[position]!=null){
tvTxtCustNo.setText(customerno[position]); //여기에서 문제의 에러가 발생합니다... 도대체 정확한 원인이 뭔지를 모르겠습니다.. ㅠ
}
if (kname[position]!=null){
tvTxtName.setText(kname[position]);
}
tvTxtCustNo.setText(customerno[position]);
return view;
//return super.getView(position, convertView, parent);
}
}
}
안녕하세요 getView 클래스에서 ...
tvTxtCustNo.setText(customerno[position]);
이것이 에러가 납니다... ㅠㅠ NullPointException이라고 나는 것 같은데... 틀림없이 customerno[position]은 널값이 아니고.. 미치겠습니다.. ㅠㅠ
고수님들 도와주세요ㅠㅠ
tvTxtCustNo 가 널이네요 이건....
findViewById 이걸 그냥 쓰면 안되구요 view.findViewById 로 쓰셔야 합니다.
view에 있는 넘을 찾는거니까요...
그리고 참고로 convertView 넘어오는거 될수 있으면 재활용하세요.
퍼포먼스에서 많은 차이가 있고 재활용 안하믄 Memory Leak도 발생할 수 있습니다.