xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
andr" />
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
andr" />
activity_main.xml
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
tools:context="com.sam.web.autocompletetext.MainActivity">
android:gravity="center"
android:textColorHint="#2294ff"
android:textStyle="bold|italic"
android:textSize="20sp"
android:hint="Enter your country_name"
android:id="@+id/autoCompleteTextViewId"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
MainActivity.java
package com.sam.web.autocompletetext;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private AutoCompleteTextView autoCompleteTextView;
private String[] countryNames;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
countryNames=getResources().getStringArray(R.array.country_name);
autoCompleteTextView=(AutoCompleteTextView) findViewById(R.id.autoCompleteTextViewId);
ArrayAdapter
autoCompleteTextView.setThreshold(1);
autoCompleteTextView.setAdapter(adapter);
autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
String value=autoCompleteTextView.getText().toString();
Toast.makeText(getApplicationContext(),value,Toast.LENGTH_SHORT).show();
}
});
}
}
string.xml
thistimebd Bangladesh Live online newsportal, education, Lifestyle, Health, Photography, gif image etc.
Make your own name or company name website | contact: thistimebd24@gmail.com
Copyright © 2020-2024 News Portal in Bangladesh - THISTIMEBD.COM. ALL Rights Reserved.