我正在尝试将AutoCompleteTextView
结果设置为Listview
。因此ListView
中的结果很明显。我尝试了太多次,但我不会得到输出。这是我在我的程序中使用的代码。
请帮帮我。
tvStart_Location.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
flag = 0;
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialogue_auocomplete);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
dialog.getWindow().setAttributes(lp);
dialog.show();
ivClear = (ImageView) dialog.findViewById(R.id.ivClear);
tvCancel = (TextView) dialog.findViewById(R.id.tvCancel);
tvStartLocation_one = (CustomAutoCompleteTextView) dialog
.findViewById(R.id.tvStartLocation_one);
tvStartLocation_one.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
placesTask = new PlacesTask();
placesTask.execute(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});
tvStartLocation_one
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
hideKeyboard(tvStartLocation_one);
st = tvStartLocation_one.getText().toString();
tvStart_Location.setText(st);
dialog.dismiss();
try {
geocoder = new Geocoder(getActivity(),
Locale.getDefault());
address1 = geocoder.getFromLocationName(st,
5);
Address location1 = address1.get(0);
lat1 = (float) location1.getLatitude();
log1 = (float) location1.getLongitude();
} catch (Exception e) {
e.printStackTrace();
}
}
});
ivClear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvStartLocation_one.setText("");
}
});
tvCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
dialog.dismiss();
}
});
dialog.show();
}
});