Pegar lista de imagens dentro do app

  • Respostas:0
Fabricio Aguiar
  • Posts no fórum: 1

09/05/2016, 06:51:50 via Web

Boa noite,

Sou novo em Android e estou com um problema em setar os caminhos das imagens em um int Array.
As imagens está dentro do App

Eu criei este código:

ContextWrapper cw = new ContextWrapper(getApplicationContext());
        // path to data/data/yourapp/app_data/imageDir
        new_folder = cw.getDir(pasta, Context.MODE_PRIVATE);

        ArrayList<String> arquivos = new ArrayList<String> ();

        if (!new_folder.exists()){
            new_folder.mkdir();
        }
        // verifica a pasta se tem arquivo //
        File[] files = new_folder.listFiles();

        if ((files.length > 0)) {
            String[] fileArray = new String[files.length];
            int[] fileArrayInt = new int[files.length];
            for (int i = 0; i < files.length; ++i) {
                fileArray[i] = files[i].getAbsolutePath();
            }

Este código está funcionando perfeitamente, o meu problema eh que eu preciso colocar os dados em um Int Array desta forma:

private int[] image_resources = {R.drawable.image01, R.drawable.image02, R.drawable.image03,
        R.drawable.image04, R.drawable.image05, R.drawable.image06, R.drawable.image07, R.drawable.image08};

trocar onde esta com os R.drawable.image01 pelos caminhos das imagens.

esta variavel image_resources estou utilizando para carregar em um Page View, neste Page View eu uso:

imageView.setImageBitmap(
            decodeSampledBitmapFromResource(resource,
                    image_resources[position],
                    1080,
                    2560));

esse método é do google para decodificar a imagem que está em HD e não dar erro.

Responder