Android Autocompletetextview到listview [英] Android Autocompletetextview to listview

查看:189
本文介绍了Android Autocompletetextview到listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

m创建一个Android应用程序,其中我有一个Autocompletetextview。当我搜索Autocompletetextview中的任何项目时获取项目列表..



我的查询是在点击Autocompletetextview中的项目之后我应该转到下一个活动打开一个新页面..



任何人都可以告诉我如何实现这?? :(

解决方案

请参阅文档 [ ^ ] for处理程序可以捕获的不同事件。


所以你最终决定使用 AutoCompleteTextView [ ^ ]

要回答这个问题,请参阅以下示例代码,这是我对您之前问题的回答的扩展:

1.从包含AutoCompleteTextView的活动中获取找到的项目并导航到新活动说NewActivity.java:

 // import android.widget.AutoCompleteTextView; 
AutoCompleteTextView autoCompleteTextView =(AutoCompleteTextView)
findViewById(R.id.autoCompleteTextView);

ArrayAdapter adapter = ArrayAdapter.createFromResource(this,
R.array.zodiac,android.R.layout.select_dialog_item);

autoCompleteTextView.setThreshold(1);

autoCompleteTextView.setAdapter(adapter);

autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener(){

public void onItemClick(AdapterView<?> arg0,View arg1,int arg2,long arg3){

String foundItem = arg0.getItemAtPosition(arg2).toString();
Log.i(你选择了--->,foundItem);

Intent newIntent = new Intent(getApplicationContext(),NewActivity.class);
newIntent.putExtra(foundItem,foundItem);
startActivity(newIntent);
}
}) ;



2.在NewActivity.java中:

 Intent intent = getIntent; 
Bundle bundle = intent.getExtras();
String foundItem = bundle.getString(foundItem);



最后但并非最不重要的,你应该承认有帮助的解决方案(过去和现在)。 / BLOCKQUOTE>

Hello,
m creating an android application in which i have a Autocompletetextview .when i search any item in Autocompletetextview i m getting item list..

My query is after clicking on the item from Autocompletetextview i it should move to next activity opening a new page..

can anybody tell me how i can achieve this??:(

解决方案

See the documentation[^] for the different events that can be caught by your handlers.


So you have finally decided to use AutoCompleteTextView[^]
To answer this question, see the following sample code, this is an extension from my answer to your earlier question:
1. From the activity that contains the AutoCompleteTextView to pick up the found item and navigate to a new activity say "NewActivity.java":

// import android.widget.AutoCompleteTextView;
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView)
        findViewById(R.id.autoCompleteTextView);

ArrayAdapter adapter = ArrayAdapter.createFromResource(this,
        R.array.zodiac, android.R.layout.select_dialog_item);

autoCompleteTextView.setThreshold(1);

autoCompleteTextView.setAdapter(adapter);

autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

        String foundItem = arg0.getItemAtPosition(arg2).toString();
        Log.i("You have selected --->", foundItem );

        Intent newIntent = new Intent(getApplicationContext(), NewActivity.class);
        newIntent.putExtra("foundItem", foundItem );
        startActivity(newIntent);
    }
});


2. In the "NewActivity.java":

Intent intent = getIntent;
Bundle bundle = intent.getExtras();
String foundItem = bundle.getString("foundItem ");


Last but not least, you should acknowledge the solutions (past and present) that help.


这篇关于Android Autocompletetextview到listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆