【发布时间】:2013-04-15 06:31:56
【问题描述】:
我需要在 android 中创建一个search box,它会检查来自arraylist 的数据,如果它在那里,它将返回到该页面。
代码:
String[] text = { "One", "Two", "Three", "Four", "Five", "Six", "Seven",
"Eight", "Nine", "Ten" };
edittext.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s)
{
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after)
{
}
public void onTextChanged(CharSequence s, int start,
int before, int count)
{
textlength = edittext.getText().length();
text_sort.clear();
image_sort.clear();
for (int i = 0; i < text.length; i++)
{
if (textlength <= text[i].length())
{
if (edittext.getText().toString().
equalsIgnoreCase((String) text[i].subSequence(0, textlength)))
{
}
}
}
我得到了search functionality 的上述代码但我需要当用户将search any keyword 时,它将从array list 进行检查,如果它在那里它将返回到该页面,否则它将显示no data found!
【问题讨论】: