, 나는 여기에 코드를 공유합니다 : android.R.layout.simple_list_item_1
public class MyXYZAdapter extends ArrayAdapter<XYZ> {
//other stuff
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater li = (LayoutInflater)
c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(R.layout.list_item_xyz, null);
}
//Object o = v.findViewById(...);
return v;
}
//other stuff
}
은 이제 list_item_xyz.xml 레이아웃 파일을 작성해야 . listalayout.xml은
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
// We came from the scanning activity; the return intent contains a RESULT_EXTRA key
// whose value is an ArrayList of BarcodeResult objects that we found while scanning.
// Get the list of objects and add them to our list view.
if (resultCode == RESULT_OK)
{
ArrayList<BarcodeResult> barcodes = data.getParcelableArrayListExtra(BarcodeScanActivity.RESULT_EXTRA);
if (barcodes != null)
{
for (int i =0;i<barcodes.size();i++)
{
bcResultArray.add(barcodes.get(i).barcodeString);
}
ListView barcodeList = (ListView) findViewById(R.id.listView1);
ListAdapter customAdapter = new MyXYZAdapter(this, R.layout.listalayout, bcResultArray);
barcodeList.setAdapter(customAdapter);
}
}
}
public class MyXYZAdapter extends ArrayAdapter<String> {
private final List<String> list;
public MyXYZAdapter(Context context, int resource, List<String> items) {
super(context, resource, items);
list = items;
}
//other stuff
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi;
vi = LayoutInflater.from(getContext());
v = vi.inflate(R.layout.listalayout, null);
}
TextView tv1 = (TextView) v.findViewById(R.id.lltitulo);
tv1.setText(list.get(position));
NumberPicker np = (NumberPicker) v.findViewById(R.id.numberPicker1);
np.setMaxValue(999);
np.setMinValue(0);
np.setValue(1);
return v;
}
//other stuff
}
당신이 numberpicker 무엇을 의미합니까합니다 (numberPicker 포함) 내가 각 라인에 표시 할 구성 요소가? – Pavlos
다음과 같은 목록보기가 필요합니다. http://img706.imageshack.us/img706/7056/nti8.jpg – Igor
목록보기에 대해 고유 한 어댑터를 작성한 다음 그에 맞게 채워야합니다! 어댑터를 사용하는 것은 쉽지 않을 것입니다! 여기에서 기본 사항을 배울 수 있습니다. http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/ – Pavlos