AutoComplete fixed selection?

How do i have an AutoComplete selection based on alphabetic instead of fixed switch cases? The situation is, everything working except when i input keyword with "B" showing Badrul as first suggestion but when clicked it will still refer to the first switch cases which is opening up Adidas.class instead of Badrul.class Please help, i am new in this. Is AutoComplete suitable for my requirement? public class Search extends Activity { public void onCreate(Bundle savedInstanceSate) { super.onCreate(savedInstanceSate); setContentView(R.layout.searchshop); AutoCompleteTextView autoComplete = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1); ArrayAdapter adapter = new ArrayAdapter(this, R.layout.list_item, shops); autoComplete.setAdapter(adapter); autoComplete.setThreshold(1); autoComplete.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView arg0, View arg1, int position, long arg3) { switch(position) { case 0: startActivity(new Intent(Search.this, Adidas.class)); break; case 1: startActivity(new Intent(Search.this, Affin.class)); break; case 2: startActivity(new Intent(Search.this, AlamArt.class)); break; case 3: startActivity(new Intent(Search.this, Badrul.class)); break; } } }); } static final String[] shops = new String[] { "Adidas", "Affin Bank", "Alam Art Gallery", "Badrul" }; }
Look at my answer below.

以上就是AutoComplete fixed selection?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏