Application returns null when instantiating custom component

1

Good evening.

I need to make a AutoCompleteTextView component search the information directly from the server and for this I am following the following article:

link

When I run the application it returns an error in this part of the XML saying that the class was not found since the path of the .java file is correct:

<br.com.aplicacao.components.DelayAutoCompleteTextView
        android:id="@+id/et_book_title"
        android:inputType="textCapSentences"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingRight="@dimen/padding_auto_complete"
        android:imeOptions="flagNoExtractUi|actionSearch"/>

Method% com_of% of Activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.a_register_emergency_service);
    this.edtDescription = (DelayAutoCompleteTextView) findViewById(R.id.edtDescription);
    this.edtCellphoneNumber = (EditText) findViewById(R.id.edtCellphoneNumber);
}

LOG:

  

09-13 20: 45: 58.329: E / AndroidRuntime (29071): Caused by: java.lang.ClassNotFoundException: Did not find class "br.aplicacao.components.DelayAutoCompleteTextView" on path: DexPathList [ zip file "/data/app/br.com.aplicacao-2.apk"],nativeLibraryDirectories=[/data/app-lib/br.com.applicacao-2, / vendor / lib, / system / lib]]

What would be the solution or is there another way to inform the class of the component?

EDIT

Fixed by putting onCreate , but now in <components.DelayAutoCompleteTextView /> when instantiating the component variable is always returning null.

    
asked by anonymous 14.09.2015 / 01:51

1 answer

1

Resolved, it follows to anyone who has the same problem regarding null instantiation:

The second problem was in the onCreate method of the component, where it was necessary to pass two parameters in the super, and not only one that would be Context , those who need to do the same do not forget to declare as follows: / p>

public DelayAutoCompleteTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

And not this way as I was doing before:

public DelayAutoCompleteTextView(Context context, AttributeSet attrs) {
    super(context);
}
    
14.09.2015 / 03:26