public class Review extends Activity {
private CustomAutoCompleteView autoComplete;
private ArrayAdapter<String> autoCompleteAdapter;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.review);
System.out.print("1");
autoCompleteAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line);
System.out.print("2");
autoCompleteAdapter.setNotifyOnChange(true); d
autoComplete = (CustomAutoCompleteView) findViewById(R.id.autoCompleteTextView1);/*Line which is unable to cast throws Exception*/
autoComplete.setHint("Restaurant Name");
autoComplete.setThreshold(3);
autoComplete.setAdapter(autoCompleteAdapter);
autoComplete.addTextChangedListener(textChecker);
final EditText et1=(EditText)findViewById(R.id.editText3);
}
CustomAutoCompleteView.java
public class CustomAutoCompleteView extends AutoCompleteTextView {
public CustomAutoCompleteView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public CustomAutoCompleteView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public CustomAutoCompleteView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
protected void performFiltering(final CharSequence text, final int keyCode) {
String filterText = "";
super.performFiltering(filterText, keyCode);
}
/**
* After a selection, capture the new value and append to the existing
* text
*/
@Override
protected void replaceText(final CharSequence text) {
super.replaceText(text);
}
}
AutoCompleteTextクラスをCustomAutoCompleteViewにキャストできません。クラスCustomAutoCompleteViewに一致するコンストラクターが含まれていますが、実行時例外がスローされます。助けてください。