【问题标题】:How to get the src from an ImageButton in Android?如何从 Android 中的 ImageButton 获取 src?
【发布时间】:2016-08-02 12:54:52
【问题描述】:

我正在构建 Activity 以获取有关用户宠物的信息并使用它创建一个 sqlite 数据库条目。我希望能够拍照并将 src 存储为条目中的行之一。

我目前有一个 ImageButton 显示来自 drawable 的默认图片,但是如何从 ImageButton 中提取 src?

我想如果我能做到这一点,那么让按钮可点击很容易,以便用户可以设置自己的(然后当他们点击保存按钮时,它将获取新图片的 src,否则如果他们不点击它,默认图片将被保存)

【问题讨论】:

标签: android image drawable imagebutton src


【解决方案1】:

请检查以下答案可能对您有所帮助。

Bitmap bitmap = ((BitmapDrawable)imagebutton.getDrawable()).getBitmap();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-13
    相关资源
    最近更新 更多