There is a CustomView (this View is an internal class in the MainActivity.), I want to flush it through xml , but I get an error.
Below is the View code:
public class RecordButton extends Button { boolean mStartRecording = true; OnClickListener clicker = new OnClickListener() { public void onClick(View v) { onRecord(mStartRecording); start = System.currentTimeMillis(); android.util.Log.i("Time Current ", " Time value in millisecinds " + start); if (mStartRecording) { setText("Stop recording"); } else { setText("Start recording"); } mStartRecording = !mStartRecording; } }; public RecordButton(Context ctx) { super(ctx); setText("Start recording"); setOnClickListener(clicker); } } attrs.xml
<resources> <declare-styleable name="com.example.AudioRecordTest.RecordButton"> <attr name="labelPosition" format="enum"> <enum name="left" value="0"/> <enum name="right" value="1"/> </attr> </declare-styleable> </resources> main_activity.xml
//some code <com.example.AudioRecordTest.RecordButton android:id="@+id/test1" android:layout_width="78dp" android:layout_height="wrap_content" android:layout_column="1" android:layout_gravity="center_horizontal|fill_vertical" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="Test1" /> Actually error:
`Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class com.example.AudioRecordTest.RecordButton` Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.AudioRecordTest.RecordButton" on path: DexPathList[[zip file "/data/app/com.example/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]