Write a program to display of all subjects of sixth semester using auto complete text view.

 



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

<androidx.constraintlayout.widget.ConstraintLayout 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"

    tools:context=".Main14Activity">

    <TextView        android:layout_width="wrap_content"      android:layout_height="wrap_content"

        android:layout_marginStart="44dp"

        android:layout_marginLeft="44dp"      android:layout_marginBottom="104dp"

        android:fontFamily="cursive"

        android:text="Subjects"

        android:textColor="#000"

        android:textSize="100dp" app:layout_constraintBottom_toTopOf="@+id/autoCompleteTextView"        app:layout_constraintStart_toStartOf="@+id/autoCompleteTextView" />

    <AutoCompleteTextView        android:id="@+id/autoCompleteTextView"

        android:layout_width="370dp"

        android:layout_height="40dp"

        android:layout_marginTop="260dp"

        android:layout_marginEnd="8dp"

        android:layout_marginRight="8dp"        android:background="@drawable/round_button"

        android:elevation="5dp"

        android:hint="Search..."

        android:paddingLeft="10dp"

        android:text=""       app:layout_constraintEnd_toEndOf="parent"   app:layout_constraintStart_toStartOf="parent"      app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Java file

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;

import android.os.Bundle;

import android.widget.ArrayAdapter;

import android.widget.AutoCompleteTextView;


public class Main14Activity extends AppCompatActivity {

    String[] language ={"Mobile Application development","Php","Python","Management"};

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main14);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>

                (this,android.R.layout.select_dialog_item,language);

        //Getting the instance of AutoCompleteTextView

        AutoCompleteTextView actv =  (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView);

        actv.setThreshold(1);

        actv.setAdapter(adapter);

        actv.setTextColor(Color.BLACK);

    }

}


Output:



Comments

Popular posts from this blog

Write a Program to accept and display the student information

Write a Program to create a toggle button to display the ON/OFF Bluetooth on the display screen.

Write a program to create a first display screen on any search engine using auto complete text View