Auto Complete Text View :
In Auto
Complete Text View whenever we start writing a text in the Edit View than
it will automatically show the available
options related to that text as you stored in an array or in a database.
You can see the example shown in the following screenshot :
In this example, I am storing the available options
in the array and than just set the adapter for simple dropdown list available
in android environment with that list.
To make this type of application you need to use the
AutoCompleteTextView class available
in android environment rather than simple TextView or EditView.
Let’s start coding by creating a project in Eclipse
: File => New => Android
Application Project and give a package name as com.javalanguageprogramming.autocompletetextdemo.
Copy the code for activity_main.xml as shown below :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<AutoCompleteTextView
android:id="@+id/autoText"
android:layout_width="220dp"
android:layout_height="50dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="50dp"
/>
</LinearLayout>
In this xml file I am using AutoCompleteTextView for
completing of text automatically from String array.
Now consider the code for Main.java as shown below :
package com.javalanguageprogramming.autocompletetextdemo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends Activity {
AutoCompleteTextView autoText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//initialize auto complete text view
autoText = (AutoCompleteTextView)findViewById(R.id.autoText);
//make an array for the suggestions
String[] suggest = {"aa", "all", "auto", "ask", "bb", "bat", "bad", "back", "ball", "cat", "java", "Program", "tutorial"};
//make an array adapter for viewing string array
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_dropdown_item_1line, suggest);
//set the adapter to the auto complete text view
autoText.setAdapter(adapter);
}
}
In this Activity, a String array named as “suggest”
is used to provide the available options and ArrayAdapter for providing the
views to the drop down list.
Thanks for sharing the information. It is very useful for my future. keep sharing
ReplyDeletebaixar facebook
baixar whatsapp
unblocked games
nice post for sharing Java article. its really helpful for me. keep shring on updated tutorials????????????????
ReplyDeleteThank u for Sharing a good and useful information. Keep Sharing These type of articles
ReplyDeleteHadoop Training in Hyderabad
Java Training in Hyderabad
Madaalarqam we provide best electronic trade platforms for consumer and reseller. We also develop all types of Programming applications
ReplyDeleteThis comment has been removed by the author.
ReplyDelete
ReplyDeleteNice blog Content.It is very informative and helpful. Please share more content. Thanks.
JAVA Training
JAVA Course
JAVA Institute
CIIT Noida provides Best MCA Courses in Noida based on the current
ReplyDeleteIT industry standards that help students to get high paying jobs in Top MNCs. CIIT provides Best MCA Training in Noida, Greater Noida, and Ghaziabad.
CIIT is one of the trusted MCA training institutes in Noida providing practical knowledge and 100% job assistance with basic as well as advanced
level MCA subjects. CIITN is the best MCA college in Noida, greater noida, ghaziabad, delhi, gurgaon regoin.
At CIIT MCA classes in Noida is conducted by subject experts corporate professionals with 9+ years of experience in managing real-time and live
projects. Sofracle Nano Specialized MCA classes Noida is the perfect blend of academic learning and practical sessions to provide maximum exposure to
students that transform an average student into a corporate professional whom companies prefer to hire.
Best MCA College in Noida
CIITN provides Best java training in noida based on current industry standards that helps attendees to secure placements in their dream jobs at MNCs.The curriculum of our Java training institute in Noida is designed in a way to make sure that our students are not just able to understand the important concepts of the programming language but are also able to apply the knowledge in a practical way.
ReplyDeleteif you are looking for the best oracle sql certification center in Noida, CIIT is worth to consider. CIIT is a oracle training institute offering best sql course, oracle training, sql certification and oracle dba training at affordable price. Best Oracle training in Noida.
Java Training in Noida
best java training in noida
Best MCA
ReplyDeletecolleges in noida
Best MSC IT
colleges in noida
Best M
TECH colleges in noida
Great post. Needed to write simple word that Thanks for suggestions. Keep it up! best sap simple finance online training institute in hyderabad
ReplyDeleteThose guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.
ReplyDeletepython Training in Bangalore | python Training in Bangalore
thank you for sharing useful post.
ReplyDeleteAndroid programming tutorial
welookups
Spot on with this write-up, I truly believe that this amazing site needs much more attention. I’ll probably be returning to read through more, thanks for the information!
ReplyDeleteJava Courses in Bangalore
I got what i am seraching from last few days in your Blog. I hope you will share more info about it. Please keep sharing.
ReplyDeleteLaptop Service center in Ameerpet
Dell Service center in Ameerpet
HP Service center in Ameerpet
Lenovo Service center in Ameerpet
Thank you for sharing Amazing Blog. It's providing very useful guideline for Engineering students.
ReplyDeleteget more: Java Programming
I need to to thank you for your time due to this fantastic read!! I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
ReplyDeleteJava Training in Bangalore
Hey there, You've done an excellent job. I will definitely digg it and personally recommend to my friends. I'm confident they'll be benefited from this website.mac reparieren berlin
ReplyDeleteThanks for sharing this informative content here. Learn Abstract Class and Interface in Java
ReplyDeletewesome article! You are providing us very valid information. This is worth reading. Keep sharing more such articles. Get All JAVA Tutorials In one place , Thank you very much! ❤❤❤
ReplyDeleteKafka clusters are fully managed for event-driven architectures. We provide 24/7 Kafka operations support for both managed and self-owned installations. Apache Kafka comes with its own set of deployment complexities as a distributed system for collecting, storing, and processing data.
ReplyDeletehttps://genexdbs.com/
Phanom Professionals Company in Bangalore provides you with a variety of JAVA software development services for the improvement of your website. We offer competitively cost services for integrating Java, developing Java websites, creating Java programs, creating Java mobile applications, migrating Java, and creating Java content management systems. Software Development Company in Bangalore is always available for you.
ReplyDeleteThank you for the information. If you are a programmer and your are facing really bad situation with your laptop then no need to worry. Here the company ITFUX24 can help you to solve your problem. Look for their computer reparatur service today and enjoy the discount.
ReplyDeleteThis Article is really helpful for me. I am pursuing Java training from Fullstack Guru's Java Classes In Pune
ReplyDeleteThis article is very helpful for me. Check out the course MERN Stack Training Program
ReplyDeleteThank you so much for writing such a lovely essay.
ReplyDeletePay Someone To Take My Online Class For Me
Great, post is so informative and helpfull to everyone , keep posting and checkout my blog java course in pune
ReplyDeletevery informative post, Full Stack Classes In Pune>
ReplyDeletegreat post. Ethical Hacking Classes In Pune
ReplyDeleteThanks for sharing this informative content here. java training in noida
ReplyDeleteThanks for the post.
ReplyDeleteJava classes in Pune