Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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??:(
Posted

See the documentation[^] for the different events that can be caught by your handlers.
 
Share this answer
 
Comments
vn12 30-Oct-14 10:29am    
which event is useful for my query??
[no name] 30-Oct-14 10:50am    
Why not read the documentation and decide for yourself which one fits your requirements?
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.
 
Share this answer
 
Comments
Member 10616184 14-May-18 0:56am    
I don't want the text to get automatically entered into the autocompletetextview. Is there any way to do that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900