hello m working on Autocompletetextview..i have two array of strings..Brand and company ..
My query is when m searching in Autocompletetextview it is not searching through Only Brand keyword..it is seaching thorgh both company and Brand..
i want to search only through Brand..how to do this???
Here is my code:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.SimpleAdapter;
public class MainActivity extends Activity {
String[] Brand = new String[]{ "XXXXX", "XXXXX", "XXXXX",
"XXXXX", "XXXXX", "XXXXX", "XXXXX", "XXXXX",
"XXXXX", "XXXXX" };
String[] Company = new String[]{ "XXXXX", "XXXXX",
"XXXXX", "XXXXX", "XXXXX", "XXXXX",
"XXXXX", "XXXXX", "XXXXX", "XXXXX" };
String[] Strength=new String[]
{
"(10 mg)",
"(10 mg)",
"(30 mg)",
"(10 mg)",
"(80 mg)",
"(10 mg)",
"(40 mg)",
"(10 mg)",
"(50 mg)",
"(10 mg)"
};
int[] flags = new int[]{
R.drawable.XXXXX,
R.drawable.XXXXX,
R.drawable.XXXXX,
R.drawable.XXXXX,
R.drawable.XXXXX,
R.drawable.XXXXX,
R.drawable.XXXXX,
R.drawable.XXXXX,
R.drawable.XXXXX,
R.drawable.XXXXX
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<hashmap><string,string>> aList = new ArrayList<hashmap><string,string>>();
for(int i=0;i<10;i++){
HashMap<string,> hm = new HashMap<string,string>();
hm.put("Brand", Brand[i]);
hm.put("flag", Integer.toString(flags[i]) );
hm.put("Strength", Strength[i]);
hm.put("Company",Company[i] );
aList.add(hm);
}
String[] from = {"flag","Brand","Company","Strength"};
int[] to = { R.id.flag,R.id.Brand,R.id.Company,R.id.Strength};
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), aList, R.layout.autocomplete_layout, from, to);
CustomAutoCompleteTextView autoComplete = ( CustomAutoCompleteTextView) findViewById(R.id.autocomplete);
OnItemClickListener itemClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView
HashMap<string,> hm = (HashMap<string,>) arg0.getAdapter().getItem(position);
}
};
autoComplete.setOnItemClickListener(itemClickListener);
autoComplete.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}