Professional Documents
Culture Documents
Practical:12
Department of Computer
Engineering/Information Technology
tools:context=".MainActivity"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/titletxt"
android:layout_width="match_parent"
android:layout_height="69dp"
android:background="#000000"
android:gravity="center"
android:text="DETAILS"
android:textColor="#FFFFFF"
android:textSize="35sp"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="@+id/listrc"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#D62727"
android:backgroundTint="#3D90B1"
tools:listitem="@layout/listitem">
</ListView>
</LinearLayout>
</LinearLayout>
import android.content.Intent
import android.os.AsyncTask
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ListView
import org.json.JSONArray
import java.net.URL
list = findViewById(R.id.listrc)
val arr = listitems
list.setOnItemClickListener { parent, view, position, id ->
val id: String = arr[position]._id.toString()
val name: String = arr[position].name.toString()
val num: String = arr[position].phone.toString()
val addr: String = arr[position].address
}
contacts().execute()
"https://api.npoint.io/f900af304ae53adffa75"
).readText(
Charsets.UTF_8
)
for (i in 0..7) {
}
}
}
Listitem.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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listindiv"
android:layout_marginTop="10dp"
>
<com.google.android.material.card.MaterialCardView
android:id="@+id/list_cardview"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
>
<TextView
android:id="@+id/list_Id"
android:text="ID"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="15sp" >
</TextView>
<TextView
android:id="@+id/list_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:text="ABCDEF"
android:textColor="@color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/list_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginLeft="10dp"
android:text="Abraham Lincoln"
android:textColor="@color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/list_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="15dp"
android:text="Abraham Lincoln"
android:textColor="@color/black"
android:textSize="15sp" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
Contact.kt
companion object{
ContctAdapter.kt
package com.example.practical_12_19012021017
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
id.text=items[position]._id
name.text=items[position].name
num.text=items[position].phone
address.text=items[position].address
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.practical_12_19012021017">
<uses-permission android:name="android.permission.INTERNET"></uses-
permission>
<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/Theme.practical_12_19012021017">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
String.xml
<resources>
<string name="app_name">practical_12_19012021017</string>
</resources>
Output :