私はベトナム人で、自分の言語でアプリに Autocomplete TextView を使用しています。AutoComplete TextView を作成したいのですが、AutoComplete TextView に「ban」と入力すると、「bạn」または「bán」または「bàn」を見つけたいことがわかります。つまり、私の言語の「a」文字は、á または ạ または à として理解できます。どうやってやるの。
public class Google extends Activity {
AutoCompleteTextView edSearch;
RelativeLayout.LayoutParams layoutParams;
RelativeLayout rl;
RelativeLayout rl1;
ImageView img1;
ImageView img2;
ImageView img3;
ImageView img4;
ImageView img5;
ImageView img6;
ImageView logoGoogle;
int status = 0;
int keyboardstatus = 0;
DatabaseHelper database;
final ArrayList<String> array = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_google);
Intent returnIntent = new Intent();
setResult(Activity.RESULT_OK, returnIntent);
database = new DatabaseHelper(this);
getListProduct();
status = 0;
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, array);
edSearch = (AutoCompleteTextView) findViewById(R.id.search);
rl = (RelativeLayout) findViewById(R.id.mylayout);
rl1 = (RelativeLayout) findViewById(R.id.mylayout1);
final Intent intent = new Intent(this, SecondActivity.class);
img1 = (ImageView) findViewById(R.id.img1);
img2 = (ImageView) findViewById(R.id.img2);
img3 = (ImageView) findViewById(R.id.img3);
img4 = (ImageView) findViewById(R.id.img4);
img5 = (ImageView) findViewById(R.id.img5);
img6 = (ImageView) findViewById(R.id.img6);
img1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("message", "Ebay");
startActivity(intent);
}
});
img2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("message", "Tiger");
startActivity(intent);
}
});
img3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("message", "Nice logo");
startActivity(intent);
}
});
img4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("message", "adidas");
startActivity(intent);
}
});
img5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("message", "b");
startActivity(intent);
}
});
img6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("message", "Nice");
startActivity(intent);
}
});
logoGoogle = (ImageView) findViewById(R.id.googlelogo);
edSearch.setBackgroundResource(R.drawable.focus_edittext);
edSearch.setAdapter(adapter);
edSearch.setThreshold(1);
edSearch.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int index = array.indexOf(edSearch.getText().toString());
// System.out.println(array.get(index) + " : " + index); //check it now in Logcat
intent.putExtra("message", array.get(index));
startActivity(intent);
edSearch.setText("");
}
});
layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
final float d = this.getResources().getDisplayMetrics().density;
int top = (int) (300 * d);
int left = (int) (20 * d);
int right = (int) (20 * d);
layoutParams.setMargins(left, top, right, 0);
edSearch.setLayoutParams(layoutParams);
rl.setBackgroundResource(R.color.white);
rl1.setBackgroundResource(R.color.white);
edSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
performSearch();
return true;
}
if (event.getAction() == KeyEvent.ACTION_UP) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
edSearch.setText("da back");
}
}
return false;
}
});
//---------
//-------
edSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
status = 1;
// Toast.makeText(getApplicationContext(), status + " khi da click ", Toast.LENGTH_SHORT).show();
final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) edSearch.getLayoutParams();
ValueAnimator animator = ValueAnimator.ofInt(params.topMargin, 0);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
params.topMargin = (Integer) valueAnimator.getAnimatedValue();
edSearch.requestLayout();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edSearch.getWindowToken(), 0);
}
});
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
layoutParams.setMargins(0, 0, 0, 0);
edSearch.setLayoutParams(layoutParams);
rl.setBackgroundResource(R.color.dark);
getApplication().setTheme(R.style.BlackTheme);
img1.setColorFilter(R.color.dark);
img2.setColorFilter(R.color.dark);
img3.setColorFilter(R.color.dark);
img4.setColorFilter(R.color.dark);
img5.setColorFilter(R.color.dark);
img6.setColorFilter(R.color.dark);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(edSearch, InputMethodManager.SHOW_IMPLICIT);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animator.setDuration(200);
animator.start();
}
});