Auto_Complete_Text_View

 MainActivity -


package com.example.autocompletetextview;


import androidx.appcompat.app.AppCompatActivity;


import android.os.Bundle;

import android.widget.ArrayAdapter;

import android.widget.AutoCompleteTextView;


public class MainActivity extends AppCompatActivity {

    AutoCompleteTextView autoCompleteTextView;

    String string []={"Pune","mumbai","konkan","Kerala","Manipur","Ahmdabad","Beed","Chhatisghar","Daund"};

    ArrayAdapter arrayAdapter;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        autoCompleteTextView=findViewById(R.id.city);

        arrayAdapter=new ArrayAdapter(MainActivity.this,android.R.layout.simple_list_item_1,string);

        autoCompleteTextView.setAdapter(arrayAdapter);

        autoCompleteTextView.setThreshold(1);

    }

}


----------------------------------------------------------------------------------------------------------------------


activity_main -


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    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:orientation="vertical"

    tools:context=".MainActivity">


   <AutoCompleteTextView

       android:layout_width="match_parent"

       android:layout_height="wrap_content"

       android:id="@+id/city"

       android:hint="Select City"/>


</LinearLayout>


-----------------------------------------------------------------------------------------------------------------------


AndroidManifest -


<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.example.autocompletetextview">


    <application

        android:allowBackup="true"

        android:icon="@mipmap/ic_launcher"

        android:label="@string/app_name"

        android:roundIcon="@mipmap/ic_launcher_round"

        android:supportsRtl="true"

        android:theme="@style/AppTheme">

        <activity android:name=".MainActivity">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>


</manifest>

Comments

Popular posts from this blog

Generate Signing Release keystore

πŸš€ COMPLETE CI/CD FROM SCRATCH

Camera Application