2014-01-20 44 views
1

我希望你的幫助如下,我如何創建一個自定義可擴展列表,並把他們每個人保存在SD卡中的圖像,我有一個數據庫與每個圖像的路徑。創建可擴展列表與保存在SD卡中的圖像

cursor = builder.query(
      /* from */ Usuario.getInstance().getReadableDatabase(), 
      /* select */ columnsToReturn, 
      /* where */ Usuario.CPF_KEY + " = \'" + LastLoginData.getCpf() + "\'", 
      null, null, null, 
      /* order by */ Usuario.REG_ID_KEY + " ASC"); 

    listAdapter = new SimpleCursorTreeAdapter(
     this, cursor, R.layout.registro_parent, 
     new String[] { Usuario.REG_DATE_KEY, Usuario.REG_TYPE_KEY, Usuario.REG_STATUS_KEY }, 
     new int[] { R.id.textData, R.id.textRegTipo, R.id.textStatus }, 
     R.layout.registro_child, 
     new String[] { Usuario.REG_MEDIA_THUMB_KEY, Usuario.REG_INFO_KEY }, 
     new int[] {R.id.imgSnapshot2 , R.id.textComentarios }) 
    { 
     @Override 
     protected Cursor getChildrenCursor(Cursor cursor) { 

      String id = cursor.getString(cursor.getColumnIndexOrThrow(Usuario.REG_ID_KEY)); 
      SQLiteDatabase db = Usuario.getInstance().getWritableDatabase(); 

      String query = "select " + Usuario.REG_ID_KEY + ", " + Usuario.REG_MEDIA_THUMB_KEY + ", " + Usuario.REG_INFO_KEY + " from " + Usuario.REG_TABLE + " where " + Usuario.REG_ID_KEY + "='" + id + "'"; 
      Cursor cur = db.rawQuery(query, null); 

      return cur; 
     } 

     @Override 
     protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) { 
      super.bindGroupView(view, context, cursor, isExpanded); 

      ImageView img = (ImageView)view.findViewById(R.id.imageExpand); 
      if(img != null) { 
       if(isExpanded) { 
        img.setImageResource(R.drawable.btn_circulo_baixo); 
       } 
       else { 
        img.setImageResource(R.drawable.btn_circulo_dir); 
       } 
      } 

      TextView status = (TextView)view.findViewById(R.id.textStatus); 
      if(status != null) { 
       String s = status.getText().toString(); 
       if(s.equals(getString(R.string.Enviada))) { 
        status.setTextColor(0xffff0000); 
       } 
       else if(s.equals(getString(R.string.EmAndamento))) { 
        status.setTextColor(0xffffcc00); 
       } 
       else if(s.equals(getString(R.string.Atendida))) { 
        status.setTextColor(0xff00cc00); 
       } 
       else { 
        status.setTextColor(0xff808080); 
       } 
      } 

      if(isExpanded) { 
       img = (ImageView)view.findViewById(R.id.imageRodape); 

       if(img != null) { 
        img.setVisibility(View.INVISIBLE); 
       } 
      } 
      else { 
       img = (ImageView)view.findViewById(R.id.imageRodape); 
       if(img != null) { 
        img.setVisibility(View.VISIBLE); 
       } 
      } 
     } 
    }; 

    listView.setAdapter(listAdapter); 

此代碼插入的一切權利,但沒有圖片:(可以有人幫忙^^ 謝謝你們^^

如何使現在擴張將是一個幫助,如果它是另有一個例子

回答