Lab Detail


Sno Back Back Subject subject date title note
1 1 Back to subject Mobile Application Development Lab - 20A05706 (Lab) Sept. 14, 2025 AUTOCOMPLETETEXTVIEW EXAMPLE

AUTOCOMPLETETEXTVIEW EXAMPLE

E:\android\MyApplication\app\src\main\res\layout\activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<layout>
    <RelativeLayout
        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">

        <GridView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/grid"
            android:layout_margin="10dp"
            android:numColumns="auto_fit"/>

        <Spinner
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/spin"
            android:layout_below="@id/grid"
            android:layout_margin="10dp"/>


        <AutoCompleteTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/auto"
            android:layout_below="@id/spin"
            android:completionThreshold="1"
            android:layout_margin="10dp"/>
    </RelativeLayout>
</layout>

E:\android\MyApplication\app\src\main\java\com\example\myapplication\MainActivity.kt

package com.example.myapplication

import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.MediaStore
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.example.myapplication.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    var binding: ActivityMainBinding? = null


    var course=arrayOf("Android", "Java","CoreJava","Core Java","advjava","adv Java",
        "python","androidjava","javaandroid")



    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Enable edge-to-edge content
        enableEdgeToEdge()
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main)

        var autoadapter= ArrayAdapter(this,android.R.layout.simple_list_item_1, course)
        binding?.auto?.setAdapter(autoadapter)

    }
}