Application returns null when instantiating custom component

Asked

Viewed 46 times

1

Good night.

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

http://makovkastar.github.io/blog/2014/04/12/android-autocompletetextview-with-suggestions-from-a-web-service/

When I run the application returns error in this part of XML saying that the class was not found and the file path .java this 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 onCreate 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: Didn’t find class "br.com.aplicacao.components.Delayautocompletetextview" on path: Dexpathlist[[zip file "/data/app/br.com.aplicacao-2.apk"],nativeLibraryDirectories=[/data/app-lib/br.com.aplicacao-2, /vendor/lib, /system/lib]]

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

EDIT

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

1 answer

1


Solved, it goes to those who have the same problem regarding null instantiation:

The second problem was in the method onCreate of the component, where it was necessary to pass two parameters in the super, and not just one that would be the Context, who needs to do the same do not forget to state as follows:

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

And not like this as I was doing before:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.