---
title: "arrayadapter 中使用R.layout.simple_list_item_single_choice如何改变字体颜色"
author: "vocaloid"
date: "2013-07-01T10:25:47Z"
tags: []
categories: ["移动开发"]
slug: "arrayadapter-r-layout-simple-list-item-single-choice"
draft: false
lastmod: "2013-07-01T10:25:47Z"
id: 1896805
url: "https://vocaloid.iteye.com/blog/1896805"
---

[http://stackoverflow.com/questions/5563698/how-to-change-text-color-of-simple-list-item](http://stackoverflow.com/questions/5563698/how-to-change-text-color-of-simple-list-item)

匿名重写adapter的getview方法

```
ListView listView = (ListView) this.findViewById(R.id.listView);
listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, MobileMuni.getBookmarkStore().getRecentLocations()) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView textView = (TextView) super.getView(position, convertView, parent);

        String currentLocation = RouteFinderBookmarksActivity.this.getResources().getString(R.string.Current_Location);
        int textColor = textView.getText().toString().equals(currentLocation) ? R.color.holo_blue : R.color.text_color_btn_holo_dark;
        textView.setTextColor(RouteFinderBookmarksActivity.this.getResources().getColor(textColor));

        return textView;
    }
});
```