0% found this document useful (0 votes)
5 views2 pages

Practical 8th

The document contains an XML layout for an Android application with a LinearLayout and an AutoCompleteTextView. The Java code defines a MainActivity that initializes the AutoCompleteTextView with an array of names and sets up window insets for proper padding. The application is designed to provide suggestions as the user types in the AutoCompleteTextView.

Uploaded by

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

Practical 8th

The document contains an XML layout for an Android application with a LinearLayout and an AutoCompleteTextView. The Java code defines a MainActivity that initializes the AutoCompleteTextView with an array of names and sets up window insets for proper padding. The application is designed to provide suggestions as the user types in the AutoCompleteTextView.

Uploaded by

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

Practical 8th

XML: -

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout 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">

<AutoCompleteTextView
android:layout_width="200dp"
android:layout_height="70dp"
android:layout_marginTop="100dp"
android:layout_marginLeft="50dp"
android:layout_gravity="center"
android:id="@+id/at"></AutoCompleteTextView>>

</LinearLayout>

JAVA FILE: -

package com.example.bluetooth;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {


String nm[]={"sneha","sanchita","Suhani"};
AutoCompleteTextView at;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
at=findViewById(R.id.at);
ArrayAdapter<String> adp=new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,nm);
at.setAdapter(adp);
at.setThreshold(1);

}
}

OUTPUT: -

You might also like