Skip to content

Instantly share code, notes, and snippets.

@mikkipastel
Created November 6, 2016 06:41
Show Gist options
  • Save mikkipastel/f3bce7d889040c6c043d9b92dd836c2b to your computer and use it in GitHub Desktop.
Save mikkipastel/f3bce7d889040c6c043d9b92dd836c2b to your computer and use it in GitHub Desktop.
temp for search data in array value
//autocomplete
getDataNumber = (AutoCompleteTextView) rootView.findViewById(R.id.getData);
String[] dataNumber = getResources().getStringArray(R.array.data_number);
setAutoComplete(dataNumber);
//search from bus number
getDataNumber.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
String[] data = getResources().getStringArray(R.array.data);
dataNumber = getDataNumber.getText().toString();
searchData(getDataNumber, data, showResult);
return false;
}
});
public void searchData(String dataNumber, String[] data, TextView result) {
String tmp = "";
for (String s : data) {
int i = s.indexOf(dataNumber + ",");
if (i >= 0) {
// found a match to data at offset i
tmp = tmp + s + "\n";
}
}
result.setText(tmp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment