簡體   English   中英

我有這個XML,我想從這個圖像視圖獲取ID

[英]i have this XML and i want to get image from this Image View against id

我有這個XML,我想從ID的detail_prfImagView的此圖像視圖中獲取圖像並將其保存到變量中。

<ImageView
android:id="@+id/detail_prfImagView"
android:layout_width="100dp"
android:layout_height="100dp" />

調用setViewContent之后,需要在活動中執行此setViewContent

ImageView imageView = (ImgaeView) findViewById(R.id.detail_prfImagView);

要檢索與ImageView關聯的位圖,可以使用getDrawable

ImageView imageView = (ImgaeView) findViewById(R.id.detail_prfImagView);
Bitmap bitmap = null;
if (imageView.getDrawable() instanceof BitmapDrawable) {
     bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM