toxa_1995
@toxa_1995
Начинающий...

Как вывести картинку в imageView?

не получается вывести картинку из assets
public Bitmap setBitmap(String name){
        AssetManager assetManager = null;
        InputStream inputStream = null;
        try {
            assert assetManager != null;
            inputStream = assetManager.open(name);

        } catch (Exception e){
            Log.d(StaticData.log, e.getMessage());
        }

        return BitmapFactory.decodeStream(inputStream);
    }

public class GeneralInformation extends AppCompatActivity {

    TextView textViewGenInfo;
    ImageView imageView;

    Image image;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_general_info);

        textViewGenInfo = (TextView) findViewById(R.id.textViewGenInfo);
        imageView = (ImageView) findViewById(R.id.imageViewGenInfo);

        try {
            DataHelper dataHelper = new DataHelper(getApplicationContext());
            Cursor cursor = dataHelper.getCursor();
            String string = "";
            if (cursor.moveToFirst()){
                string = cursor.getString(cursor.getColumnIndexOrThrow(DataHelper.TableName.TEXT));
            } while (cursor.moveToNext());

            textViewGenInfo.setText(Html.fromHtml(string));

            image = new Image();

            imageView.setImageBitmap(image.setBitmap(getApplicationContext()
            .getExternalFilesDir("size_1.jpg").getAbsolutePath()));
        } catch (Exception e){
            Log.d(StaticData.log, e.getMessage());
        }
    }
}

73fee40abaed48d7b35d01be63a29c99.png
  • Вопрос задан
  • 202 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы