当未更新ImageView时,我该如何使用IF IF Statment



我有一个带有SRC的图像视图,我想使用if语句,当用户不更改配置文件饮食按钮视图时,无法继续

我尝试使用此,.getDrawable((== resourcescompat.getDrawable`但是不起作用

XML

   <ImageView            
            android:id="@+id/imgProfil"
            android:layout_width="96dp"
            android:layout_height="96dp"
            android:layout_below="@id/RGroupWaktu"
            android:layout_marginStart="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="-25dp"
            android:layout_marginEnd="-103dp"
            android:layout_marginRight="-103dp"
            android:layout_marginBottom="5dp"
            android:layout_toStartOf="@+id/RGroupWaktu"
            android:layout_toLeftOf="@+id/RGroupWaktu"
            android:onClick="onUploadImageClick"
            android:src="@drawable/iconrounded"
            app:civ_border_color="#ffffff"
            app:civ_border_width="2dp" />

Java if (mProfil.getDrawable()==ResourcesCompat.getDrawable(getResources(), R.drawable.iconrounded, null)

我想要当用户不替换图像视图上的映像时,用户无法继续下一个阶段

当您设置/替换图像视图上的图像时,还设置一个标签名称:

imageview.setImageResource(R.drawable.iconrounded);
imageview.setTag("iconrounded");

然后获取标签名称并检查它:

String imagename =  (String)imageview.getTag();
if(imagename!=null && imagename.equals("iconrounded")){
   //go to next Activity 
}else {
    // Show a  alert  toast  for change 
}

最新更新