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

 Xml file

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

<RelativeLayout 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"  xmlns:app="http://schemas.android.com/apk/res-auto"

    tools:context=".Main13Activity"

    android:background="#fff">

    <ImageView

        android:id="@+id/googleimg"

        android:layout_marginLeft="50dp"

        android:layout_width="300dp"        android:layout_height="wrap_content"

        android:src="@drawable/google"

        android:layout_marginTop="100dp"

        />

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

        android:layout_width="370dp"

        android:layout_height="40dp"

        android:layout_marginLeft="20dp"

        android:layout_marginTop="260dp"

        android:text=""

android:background="@drawable/round_button"

        android:elevation="5dp"

        android:hint="Search..."

        android:paddingLeft="10dp"

        />

    <Button       android:layout_width="wrap_content"       android:layout_height="wrap_content"       android:layout_below="@id/autoCompleteTextView"

        android:layout_marginLeft="65dp"

        android:layout_marginTop="40dp"

        android:text="Google search"

        android:textColor="#B4353232"

        android:background="#1D555151"

        android:padding="5dp"/>

    <Button       android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:layout_below="@id/autoCompleteTextView"

        android:layout_marginLeft="200dp"

        android:layout_marginTop="40dp"

        android:text="  I'M feeling lucky"

        android:background="#1D555151"

        android:textColor="#B4353232"

        android:padding="5dp"/>

</RelativeLayout>

.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 Main13Activity extends AppCompatActivity {

    String[] language ={"C","C++","Java",".NET","iPhone","Android","ASP.NET","PHP"};

    @Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);     setContentView(R.layout.activity_main13);ArrayAdapter<String> adapter = new ArrayAdapter<String>         (this,android.R.layout.select_dialog_item,language);

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.