0% found this document useful (0 votes)
6 views5 pages

Practical 8 A

The document outlines exercises for a Mobile Application Development course, specifically focusing on creating user interfaces using different layouts in Android. It includes a program for an AutoCompleteTextView search engine display and mentions additional exercises for arranging Name, Age, and Mobile Number using Linear and Absolute layouts. The provided code snippets demonstrate how to implement these features in an Android application.

Uploaded by

sainathkorpakwad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Practical 8 A

The document outlines exercises for a Mobile Application Development course, specifically focusing on creating user interfaces using different layouts in Android. It includes a program for an AutoCompleteTextView search engine display and mentions additional exercises for arranging Name, Age, and Mobile Number using Linear and Absolute layouts. The provided code snippets demonstrate how to implement these features in an Android application.

Uploaded by

sainathkorpakwad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Subject :- Mobile Application Developmen Subject Code :- 22617

Name :- Shivam Sainath Korpakwad Batch :- CO 6 IA Roll No. 24

Exercise :-
1). Write a program to create a first display sreen of any search engine using Auto
Complete
Text View.
Code :-
<?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"
android:padding="16dp"
tools:context=".MainActivity">
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search..."
android:imeOptions="actionSearch"
android:inputType="text"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"/>
<Button
android:id="@+id/searchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search"
android:layout_below="@id/autoCompleteTextView"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"/>
</RelativeLayout>
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity
public class MainActivity extends AppCompatActivity
private AutoCompleteTextView autoCompleteTextView;
private Button searchButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
autoCompleteTextView = findViewById(R.id.autoCompleteTextView);
searchButton = findViewById(R.id.searchButton);
String[] suggestions = {"Android", "Java", "Programming", "Development", "OpenAI", "Machine Learning"}
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
android.R.layout.simple_dropdown_item_1line, suggestions);
autoCompleteTextView.setAdapter(adapter);
searchButton.setOnClickListener(v -> {
String query = autoCompleteTextView.getText().toString();
Toast.makeText(MainActivity.this, "Searching for: " + query, Toast.LENGTH_SHORT).show()
}};
}
}
Output :-
Subject :- Mobile Application Developmen Subject Code :- 22617
Name :- Shivam Sainath Korpakwad Batch :- CO 6 IA Roll No. 24

Exercise :-

1). Write a program to place Name, Age and Mobile Number linearly (vertical) on
display
screen using Linear layout.

Code :-

Output :-
Subject :- Mobile Application Developmen Subject Code :- 22617
Name :- Shivam Sainath Korpakwad Batch :- CO 6 IA Roll No. 24

Exercise :-

2). Write a program to place Name, Age and Mobile Number centrally on the display
screen using Absolute layout.

Code :-

Output :-

You might also like