0
如何遍历这组数据?处理来自SQLite/Android的数据
String[] from = new String[]{AppSQLite.KEY_NAME,AppSQLite.KEY_ICON};
int[] to = new int[]{R.id.main_menu_list_item);
我想将它们传递到自定义简单的游标适配器和覆盖getView(),使 的KEY_NAME是文本(带的setText可能)和
setCompoundDrawablesWithIntrinsicBounds(**KEY_ICON**, 0, 0, 0);
我getView是这样的:
public View getView(int pos, View convertView, ViewGroup parent){
View v = convertView;
if(v == null){
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.icon_list_item, null);
}
this.c.moveToPosition(pos);
String name= this.c.getString(this.c.getColumnIndex(AppSQLite.KEY_NAME));
String icon= this.c.getString(this.c.getColumnIndex(AppSQLite.KEY_ICON));
TextView mName= (TextView) v.findViewById(R.id.icon_textView);
bTitle.setText(name);
mName.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
return v;
在我的数据库的图标是这种形式:
R.drawable.menu_icon TEXT
所以我认为在setCompoundDrawablesWithIntrinsicBounds
中存在另一个问题。
是的,我知道,我不知道如何使它发挥作用?我应该以另一种方式存储图像还是有像js中的eval这样的功能? –
我已经更新了我的答案。 –