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; } });
相关推荐
# simple_list_item_single_choice # simple_list_item_1 # simple_list_item_multiple_choice 3.上边的相关介绍。 ActivityList2:(有错误,没有调试成功,回头再看) 1.介绍cusor。 ...
2. ListItem布局:决定每个列表项的显示样式,如`android.R.layout.simple_list_item_1`(单行文本)、`android.R.layout.simple_list_item_2`(两行文本)、`android.R.layout.simple_list_item_single_choice`...
listView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, data)); ``` 四、SimpleAdapter SimpleAdapter 是一个ListAdapter,用于将 ArrayList 里的数据绑定到 ListView 中...
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, myStringArray); listView.setAdapter(adapter); ``` 其中,`this`代表上下文,`android.R.layout.simple_list_...
setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, GENRES)); final ListView listView = getListView(); listView.setItemsCanFocus(false); listView.setChoiceMode...
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, dataList); listView.setAdapter(adapter); ``` 这里,dataList是包含列表数据的ArrayList,`android.R.layout....
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, dataList); listView.setAdapter(adapter); ``` 其中,`dataList`是包含数据的列表,`android.R.layout.simple_list_...
Android SDK提供了几种预定义的Row Layout,如`simple_list_item_1`(单行文本),`simple_list_item_2`(标题和文本),`simple_list_item_single_choice`(单选按钮),`simple_list_item_multiple_choice`(多选...
还有其他预定义的样式可供选择,如`simple_spinner_item`,`simple_list_item_checked`,和`simple_list_item_single_choice`。 ### 将适配器绑定到Spinner 最后,我们需要将适配器设置给Spinner: ```java ...
ArrayAdapter<String> adapter = new ArrayAdapter(context, android.R.layout.simple_list_item_single_choice, items); listView.setAdapter(adapter); confirmBtn.setOnClickListener(v -> { int ...
android.R.layout.simple_list_item_single_choice, list); ListView listView = (ListView) findViewById(R.id.listView); listView.setAdapter(adapter); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE)...
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, items); gridView.setAdapter(adapter); ``` 这里的`items`是数据源,`android.R.layout.simple_list_item_1`是每个...
# simple_list_item_single_choice # simple_list_item_1 # simple_list_item_multiple_choice 3.上边的相关介绍。 ActivityList2:(有错误,没有调试成功,回头再看) 1.介绍cusor。 2.介绍CursorAdapter。 ...
ArrayAdapter<String> adapter = new ArrayAdapter(context, android.R.layout.simple_list_item_single_choice, items); listView.setAdapter(adapter); // 监听列表项点击 listView.setOnItemClickListener(...
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, dataList); listView.setAdapter(adapter); ``` 二、点击事件处理 1. 设置OnItemClickListener:为了监听ListView...
ArrayAdapter<String> adapter = new ArrayAdapter(context, android.R.layout.simple_list_item_single_choice, options); ListView listView = new ListView(context); listView.setAdapter(adapter); listView....
- **预设布局**:如`simple_list_item_1`(单行单TextView)、`simple_list_item_2`(单行双TextView)、`simple_list_item_single_choice`(单选列表项)。 - **ArrayAdapter**:ArrayAdapter用于数组数据和...
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, options); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("单选...