/**
* 提供存放在文件夹下的属性文件作为单表查询结果展示 的字段集
* @param path 属性文件的路径
* @return Bean实体封装类(String,String)
*/
public List getBeansList(String path) {
String Path = String.format(“data/%s.properties”, path);
List optionList = new ArrayList();
try {
InputStream in = getAssets().open(Path);
/**Util类中写入getBeanList方法,解析相应的.properties文件
* 此处省略了该类方法;
*/
return optionList = Util.getBeanList(in);
} catch (IOException e) {
return null;
}
}
/**
* 提供存放在a文件夹下的属性文件作为下拉选的数据源
* @param path 属性文件的路径*(%s.properties)文件
* @param id 布局文件中下拉选的id
*/
public void getOption(String path, int id) {
List<Bean> optionList = new ArrayList<Bean>();
try {
InputStream in = getAssets().open(path);
/**Util类中写入getBeanList方法,解析相应的.properties文件
* 此处省略了该类方法;
*/
optionList = Util.getBeanList(in);
} catch (IOException e) {
}
Spinner me_Spinner = (Spinner) findViewById(id);
ArrayAdapter<String> adapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_item, optionList);
adapter.setDropDownViewResource(R.layout.spinner_drop_item);
me_Spinner.setAdapter(adapter);
me_Spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
View focus = parent.getSelectedView();
focus.setFocusable(true);
focus.setSelected(true);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}