Professional Documents
Culture Documents
Practical No 8
Practical No 8
I. Practical Significance
In this practical, UI controls in android like Auto complete Text view is studied. Wherein the
UI controls can be developed, used and placed on the screen using different layout managers
as per the problem statement requirements.
number of characters defined by the threshold. Auto Complete Text View is a component used
to show suggestions while writing in an editable text field. The suggestions list is shown in a
drop-down menu from which a user can select the desired item. The list of suggestions is
obtained from an adapter and it appears only after a number of characters that are specified
in the threshold. To use an Auto Complete Threshold field, it needs to be defined in the layout.
1.
android:completionHint
Defines the hint displayed in the drop down menu.
2.
Use <AutoCompleteTextView> tag.
X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to create a first display screen of any search engine using Auto Complete
Text View.
2. Write a program to display all the subjects of sixth semester using Auto Complete Text
View.
1.
//MainActivity.java
package com.jamiapolytechnic.experiment81;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
//=====================================================================
//activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Google"
android:textSize="25sp"/>
<AutoCompleteTextView
android:id="@+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Search"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/btnSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search"
android:textSize="15sp"
android:textStyle="normal|bold" />
<Button
android:id="@+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:textSize="15sp"
android:textStyle="normal|bold" />
</LinearLayout>
</LinearLayout>
2.
//MainActivity.java
package com.jamiapolytechnic.experiment82;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
//=====================================================================
//activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:orientation="vertical"
android:id="@+id/linear_Layout">
<AutoCompleteTextView
android:id="@+id/subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:hint="Enter Subject"/>
</LinearLayout>
1
2
3
4