Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Mobile Application Development (22617) Practical No.

Practical No. 8: Develop a program to implement Auto Complete Text View

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.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools
PO 7. Ethics
PO 10. Life-long learning

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills 1. Able to develop UI controls like Auto
complete Text View.
2. Able to test UI controls like Auto complete Text View by checking its placing on the
display screen.
3. Able to build UI controls like Auto complete Text View, once testing is done and there
are no errors.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Develop a program to implement Auto complete Text View.

VI. Relevant Affective Domain Related Outcome(s) 1. Work


collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background Auto Complete Text


View:
Android Auto Complete Text View completes the word based on the reserved words, so no
need to write all the characters of the word. Android Auto Complete Text View is a editable
text field, it displays a list of suggestions in a drop down menu from which user can select only
one suggestion or value. Android Auto Complete Text View is the subclass of Edit Text class.
The Multi Auto Complete Text View is the subclass of AutoComplete Text View class. An
editable text view that shows completion suggestions automatically while the user is typing.
The list of suggestions is displayed in a drop-down menu from which the user can choose an
item to replace the content of the edit box. The drop down can be dismissed at any time by
pressing the back key or, if no item is selected in the drop down, by pressing the enter center
key. The list of suggestions is obtained from a data adapter and appears only after a given

Maharashtra State Board of Technical Education 1


Mobile Application Development (22617) Practical No. 8

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.

VIII. Resources required (Additional)

Sr. Instrument /Object Specification Quantity Remarks


No.
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1
version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must design more
such questions to ensure the achievement of identified CO.
1. What does android:completionHint attribute in Auto Complete Text view does?
2. How to create AutoCompleteTextView field in XML?

(Space for answers)

Maharashtra State Board of Technical Education 2


Mobile Application Development (22617) Practical No. 8

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.

(Space for answers)

1.
//MainActivity.java
package com.jamiapolytechnic.experiment81;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class MainActivity extends AppCompatActivity {


String[] words = { "MGT", "PWP", "MAD", "ETI", "WBP", "NIS", "DWM", "EDE", "CPE" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, words);
AutoCompleteTextView actv = (AutoCompleteTextView)findViewById(R.id.subject);
actv.setThreshold(1);
actv.setAdapter(adapter);
}
}

//=====================================================================
//activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

Maharashtra State Board of Technical Education 3


Mobile Application Development (22617) Practical No. 8

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;

Maharashtra State Board of Technical Education 4


Mobile Application Development (22617) Practical No. 8

import android.widget.AutoCompleteTextView;

public class MainActivity extends AppCompatActivity {


String[] subjects = { "MGT", "PWP", "MAD", "ETI", "WBP", "NIS", "DWM", "EDE", "CPE" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, subjects);
AutoCompleteTextView actv = (AutoCompleteTextView)findViewById(R.id.subject);
actv.setThreshold(1);
actv.setAdapter(adapter);
}
}

//=====================================================================
//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>

Maharashtra State Board of Technical Education 5


Mobile Application Development (22617) Practical No. 8

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage

Process related (10 Marks) 30%

1. Logic Formation 10%


2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%

4. Interactive GUI 20%


5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members

1
2
3
4

Marks Obtained Dated signature of


Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 6

You might also like