通过标签访问图像视图
Accessing a image view via tags
我正在开发一个 android 项目,我在其中创建了 3 个线性布局(水平)并且每个布局都有一些图像视图。我还为每个图像视图分配了标签。
我如何通过标签访问每个图像视图。
我想访问它以检查图像视图的不同条件。
标签不用于标识视图,因此您不能直接使用它来标识视图(https://developer.android.com/reference/android/view/View.html)
您需要先获取父项。
LinearLayout linearLayout = (LinearLayout)findViewById(R.id.ll_layout_1);
ImageView imageView = (ImageView) linearLayout.findViewWithTag("imageTag");
我正在开发一个 android 项目,我在其中创建了 3 个线性布局(水平)并且每个布局都有一些图像视图。我还为每个图像视图分配了标签。 我如何通过标签访问每个图像视图。 我想访问它以检查图像视图的不同条件。
标签不用于标识视图,因此您不能直接使用它来标识视图(https://developer.android.com/reference/android/view/View.html)
您需要先获取父项。
LinearLayout linearLayout = (LinearLayout)findViewById(R.id.ll_layout_1);
ImageView imageView = (ImageView) linearLayout.findViewWithTag("imageTag");