Mobile Application Development Practical 8
Question 1
Write a program to create a first display screen of any search engine using Auto Complete Text View.
activity_main.xml
<?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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="56dp"
android:layout_y="99dp"
android:text="Search" />
<AutoCompleteTextView
android:id="@+id/autoText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="138dp"
android:layout_y="83dp"
android:hint="Search here"
android:minHeight="48dp" />
</AbsoluteLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.practical8_1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends AppCompatActivity {
String[] sub={"Yahoo","Yatra","Android development","Anydesk","Area of circle","Bank of India","Bank of Baroda","Bank of Maharashtra"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AutoCompleteTextView actv=(AutoCompleteTextView) findViewById(R.id.autoText);
ArrayAdapter<String> adptr=new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,sub);
actv.setThreshold(1);
actv.setAdapter(adptr);
}
}
Output

Question 2
Write a program to display all the subjects of sixth semester using Auto Complete Text View.
activity_main.xml
<?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=".MainActivity">
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="56dp"
android:layout_y="99dp"
android:text="Enter Text" />
<AutoCompleteTextView
android:id="@+id/autoText"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="138dp"
android:layout_y="83dp"
android:hint="Enter text here"
android:minHeight="48dp" />
</AbsoluteLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.practical8;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends AppCompatActivity {
String[] sub={"MAD","MGT","EDE","PWP","ETI","PCI"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AutoCompleteTextView actv=(AutoCompleteTextView) findViewById(R.id.autoText);
ArrayAdapter<String> adptr=new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,sub);
actv.setThreshold(1);
actv.setAdapter(adptr);
}
}
Output
