2012-01-25 5 views
0

이 데이터 집합을 어떻게 트래버스 할 수 있습니까?SQLite/Android에서 데이터를 처리하십시오.

:
String[] from = new String[]{AppSQLite.KEY_NAME,AppSQLite.KEY_ICON}; 
int[] to = new int[]{R.id.main_menu_list_item); 

나는 사용자 정의 간단한 커서 어댑터로 전달하고 오버라이드 (override)의 getView()를 KEY_NAME 텍스트가 (아마의 setText로)입니다 있도록하고

setCompoundDrawablesWithIntrinsicBounds(**KEY_ICON**, 0, 0, 0); 

내의 getView이있다 할 내 DB에

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에 넣는 것에 또 다른 문제가 있다고 생각합니다.

답변

0

icon 매개 변수는 정수가 아니며 문자열입니다. 귀하의 코드에서 그것은 당신이 컴파일 오류를 줄 문자열을 전달하는 것 같습니다.

업데이트 : 일부 문자열을 데이터베이스에 저장하고 다른 드로어 블로드 로직을 작성하십시오.

상점이, icon_1, icon_2, icon_3

 
if(icon_1){ 
    use R.drawable.icon_1; 
else if(icon_2) 
    use R.drawable.icon_2; 
and so on.... 
+0

그래 나도 알아, 난 그것이 작동하는 방법을 잘 모릅니다? 내가 다른 방식으로 이미지를 저장해야합니까, 아니면 js에 eval과 같은 기능이 있습니까? –

+0

답변을 업데이트했습니다. –

관련 문제