I am using a color picker library from THIS LINK
It works well, and I want to be able to access a certain element from the XML. Here is the code I am interested in:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".ColorPicker">
<View
android:id="@+id/colorView"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:elevation="2dp"/>
<!--...-->
I am trying to access the item with colorView
id. In java code, I have this:
ColorPicker colorPicker = new ColorPicker(additionPractice.this, 0, 0, 0);
I expected to use
colorPicker.findViewById(R.id.colorView)
, but this is null
. Is there a way to access this element? I can provide more code if you want, and there is a lot of info in the Github link. I appreciate your help!
colorPicker.show();
View colorView = colorPicker.findViewById(R.id.colorView);
I just try this ,It worked!