使用保存在SD卡中的图像创建可扩展列表

时间:2014-01-20 13:53:54

标签: android android-layout layout

我想为您提供以下帮助,如何创建自定义可扩展列表并将每个列表保存在sdcard中,我有一个数据库,其中包含每个图像的路径。

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 );

此代码插入一切正确但不是图片:(有人可以帮助^ ^ 谢谢你们^ ^

现在如何制作可展开的示例将是一种帮助,如果不是这样的话。

1 个答案:

答案 0 :(得分:0)