Как получить идентификатор элемента управления из настраиваемого адаптера списка в Android?

У меня есть настраиваемый адаптер списка, содержащий макет с элементами управления. Мне было интересно, как я могу получить каждый отдельный идентификатор элемента управления? Я планирую изменить цвет некоторых текстовых представлений.

private void UpdateDisplay() {
    // define the list which holds the information of the list
    List<Map<String, Object>> resourceNames = new ArrayList<Map<String, Object>>();

    // define the map which will hold the information for each row
    Map<String, Object> data;

    if (appts.size() > 0) {
        for (int i = 0; i < appts.size(); i++) {
            data = new HashMap<String, Object>();

            data.put("apptListType", appts.get(i).getType().getName());
            data.put("apptListTime", DateFormat.getTimeInstance(
                    DateFormat.SHORT).format(appts.get(i).getStartDate())
                    + " - "
                    + DateFormat.getTimeInstance(DateFormat.SHORT).format(
                            appts.get(i).getEndDate()));
            data.put("apptListContactName", appts.get(i).getContact()
                    .getFullName());
            data.put("apptListContactCompany", appts.get(i).getContact()
                    .getCompany());
            resourceNames.add(data);
        }
    } else {

        data = new HashMap<String, Object>();

        data.put("apptListType", "No appointments found for today.");
        data.put("apptListTime", "");
        data.put("apptListContactName", "");
        data.put("apptListContactCompany", "");
        resourceNames.add(data);

    }

    apptDescription = new SimpleAdapter(this, resourceNames,
            R.layout.apptlistitem, new String[] { "apptListType",
                    "apptListTime", "apptListContactName",
                    "apptListContactCompany" }, new int[] {
                    R.id.apptListType, R.id.apptListTime,
                    R.id.apptListContactName, R.id.apptListContactCompany });
    ListView apptList = (ListView) findViewById(R.id.apptsList);
    apptList.setAdapter(apptDescription);

    apptList.setOnItemClickListener(AppointmentDailyView.this);

    apptList.setItemsCanFocus(true);

и вот мой XML-файл для каждого элемента списка:

<?xml version="1.0" encoding="utf-8"?>

<TextView android:id="@+id/apptListType" android:textSize="20px"
    android:textColor="#333" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:textStyle="bold" />

<TextView android:layout_below="@+id/apptListType" android:id="@+id/apptListTime"
    android:textSize="15px" android:textColor="#666" android:layout_width="wrap_content"
    android:layout_height="wrap_content" ></TextView>
<TextView android:layout_below="@+id/apptListTime" android:id="@+id/apptListContactName"
    android:textSize="20px" android:textColor="#333" android:layout_width="wrap_content"
    android:layout_height="wrap_content"></TextView>

<TextView android:layout_toRightOf="@+id/apptListContactName"
    android:layout_below="@+id/apptListTime" android:id="@+id/apptListContactCompany"
    android:textSize="15px" android:textColor="#666"
    android:layout_height="wrap_content" android:layout_width="wrap_content"
    android:paddingLeft="5px" android:layout_marginTop="3px"></TextView>

Любая помощь приветствуется, спасибо.

1
задан ninjasense 10 September 2010 в 22:48
поделиться