-
jiayu.lin说:
android ListPreference怎么设置selector
按钮的颜色
可以使用以下代码:
设置ListPreference的背景:
ListPreference listPreference = (ListPreference) findPreference("list_preference");
listPreference.getListView().setBackgroundColor(Color.parseColor("#ffffff"));设置ListPreference的按钮颜色:
listPreference.getListView().setSelector(R.drawable.selector_button);
-
jiayu.lin说:
android Preference 怎么设置selector
1、在res/drawable目录下新建一个xml文件,名字叫selector_example.xml,里面写入如下代码:
2、在res/values目录下新建一个xml文件,名字叫attrs.xml,里面写入如下代码:
3、在res/xml目录下新建一个xml文件,名字叫preferences.xml,里面写入如下代码:
4、在应用程序代码中,添加如下代码:
PreferenceManager manager = getPreferenceManager(); manager.setSharedPreferencesName("preferences"); addPreferencesFromResource(R.xml.preferences);
5、运行程序,就可以看到你设置的selector了。
-
jiayu.lin说:
android Preference 怎么设置selector,用code
实现
//设置Seletor
ListPreference listPreference = (ListPreference)findPreference("list_preference_key");
listPreference.setEntries(R.array.list_preference_entries);
listPreference.setEntryValues(R.array.list_preference_entry_values);
listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
//TODO
return true;
}
}); -
jiayu.lin说:
android ListPreference 怎么设置selector,用code
可以使用ListPreference的setEntries和setEntryValues方法来设置selector:
ListPreference listPreference = (ListPreference) findPreference("list_preference");
String[] entries = new String[] {"Option 1", "Option 2", "Option 3"};
String[] entryValues = new String[] {"1", "2", "3"};listPreference.setEntries(entries);
listPreference.setEntryValues(entryValues); -
gao55pan说:
请用FastAPI-Amis-Admin 实现学生列表信息管理,给出具体实现代码
# -*- coding: utf-8 -*- from fastapi import FastAPI from amis_admin import AmisAdmin app = FastAPI() admin = AmisAdmin(app) @admin.register() def student_list(): schema = { "type": "page", "title": "学生管理", "body": { "type": "crud", "name": "student_list", "controls": [ { "name": "name", "type": "input", "label": "姓名" }, { "name": "age", "type": "number", "label": "年龄" }, { "name": "gender", "type": "select", "label": "性别", "source": [ { "name": "男", "value": "male" }, { "name": "女", "value": "female" } ] }, { "name": "phone", "type": "input", "label": "电话" }, { "name": "address", "type": "input", "label": "地址" } ], "dataSource": { "type": "mock", "data": [ { "name": "张三", "age": 20, "gender": "male", "phone": "123456789", "address": "北京市朝阳区" }, { "name": "李四", "age": 25, "gender": "female", "phone": "987654321", "address": "上海市浦东新区" } ] } } } return schema