List View


MainActivity -


package com.example.listview;


import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.widget.ArrayAdapter;

import android.widget.ListView;


public class MainActivity extends AppCompatActivity {


    ListView listView;

    String string []={"Android","Java","PHP","HTML","JQuery","Jsp"};

    ArrayAdapter arrayAdapter;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        listView=findViewById(R.id.listview);

        arrayAdapter=new ArrayAdapter(MainActivity.this,android.R.layout.simple_list_item_1,string);

        listView.setAdapter(arrayAdapter);

    }


}


-----------------------------------------------------------------------------------------------------------------------------


activity_main -


<?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:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    tools:context=".MainActivity">



    <ListView

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:id="@+id/listview"

        >


    </ListView>





</LinearLayout>


----------------------------------------------------------------------------------------------------------------------------


AndroidManifest -


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

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.example.listview">


    <application

        android:allowBackup="true"

        android:icon="@mipmap/ic_launcher"

        android:label="@string/app_name"

        android:roundIcon="@mipmap/ic_launcher_round"

        android:supportsRtl="true"

        android:theme="@style/AppTheme">

        <activity android:name=".MainActivity">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>


</manifest> 

Comments

Popular posts from this blog

Generate Signing Release keystore

🚀 COMPLETE CI/CD FROM SCRATCH

Camera Application