안드로이드 개발 질문/답변
(글 수 45,052)
// 리스트뷰 아이템 클릭 이벤트
@Override
protected void onListItemClick(ListView parent, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(parent, v, position, id);
Toast.makeText(this, Integer.toString(position), Toast.LENGTH_SHORT).show();
_getBarcode = m_orders.get(position).getOthers();
_getOthers = m_orders.get(position).getBarcode();
//Person a = m_orders.get(position);
//setSelection(position);
_selectedRemove = position;
}
@Override
protected void onListItemClick(ListView parent, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(parent, v, position, id);
Toast.makeText(this, Integer.toString(position), Toast.LENGTH_SHORT).show();
_getBarcode = m_orders.get(position).getOthers();
_getOthers = m_orders.get(position).getBarcode();
//Person a = m_orders.get(position);
//setSelection(position);
_selectedRemove = position;
}
// ListView Item 두줄 출력 클래스
private class PersonAdapter extends ArrayAdapter<Person> {
private ArrayList<Person> items;
public PersonAdapter(Context context, int textViewResourceId, ArrayList<Person> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
v = convertView;
if (v == null) {
vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
p = items.get(position);
if (p != null) {
tt = (TextView) v.findViewById(R.id.toptext);
bt = (TextView) v.findViewById(R.id.bottomtext);
if (tt != null){
tt.setText(p.getOthers());
}
if(bt != null){
bt.setText(_cusName.getText().toString()+" / "+ p.getBarcode());
}
}
return v;
}
}
class Person {
private String others;
private String barcode;
public Person(String _others, String _barcode){
this.others = _others;
this.barcode = _barcode;
}
public String getBarcode() {
return barcode;
}
public String getOthers() {
return others;
}
}
위와 같이 되어있습니다. 현재는 아이템 선택시 그 position을 담아뒀다가, 버튼 등의 이벤트시
포지션에 해당하는 아이템을 삭제하고 있습니다.
private String others;
private String barcode;
public Person(String _others, String _barcode){
this.others = _others;
this.barcode = _barcode;
}
public String getBarcode() {
return barcode;
}
public String getOthers() {
return others;
}
}
위와 같이 되어있습니다. 현재는 아이템 선택시 그 position을 담아뒀다가, 버튼 등의 이벤트시
포지션에 해당하는 아이템을 삭제하고 있습니다.
그런데 리스트에서 선택시 어떤게 선택되었는지 확인 할 수 있도록 스타일을 변경해주고 싶은데...
잘 모르겠어요.... 도움이 필요합니다.
잘 모르겠어요.... 도움이 필요합니다.