MAD Exp 8
MAD Exp 8
Practical No 8:
Q. Write a Program to create a first display screen of any search engine using
AutoCompleteTextView.
CODE:
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:padding="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100sp"
android:src="@drawable/google"/>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionThreshold="1"
android:id="@+id/actv"
android:textSize="20sp"
android:layout_marginTop="50sp"
android:drawableLeft="@drawable/search"
android:drawableRight="@drawable/mic"
android:hint="Search Google or enter URL"/>
</LinearLayout>
Oaish Qazi 2|Page
JAVA:
package com.example.myapplication;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import androidx.appcompat.app.AppCompatActivity;
OUTPUT:
JAVA:
package com.example.myapplication;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
OUTPUT: