MAD Lab 3
MAD Lab 3
Objective: In this course the students will learn how to develop applications for
android mobile devices, including smartphones and tablets. Students are introduced to the
survey of current mobile platforms, mobile application development environments,
mobile device input methods, as well as developing applications for most popular mobile
platforms. Students will design and build a variety of Apps throughout the course to
reinforce learning and to develop real competency with latest ASO strategies.
Description:
Programming is an increasingly important skill, whether you aspire to a career in
software development, or in other fields. This course is the first in the specialization
Android Application Development, but its lessons extend to any language you might
want to learn like java or Kotlin. This is because programming is fundamentally about
figuring out how to solve a class of problems, development of application and writing the
algorithm, a clear set of steps to solve any problem in its class.
Assessment tools:
The assessment is according to the student participation in the lab if the student solves the
exercise, he will get the participation mark for this lab.
package com.example.senthil.kotlin_listview.Activity
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.AdapterView
import android.widget.ListView
import com.example.senthil.kotlin_listview.Adapter.ListViewModelAdapter
import com.example.senthil.kotlin_listview.R
import com.example.senthil.kotlin_listview.Utils.Helper
}
}
}
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.example.senthil.kotlin_listview.Model.ListViewModel
import com.example.senthil.kotlin_listview.R
if (convertView == null) {
val layoutInflater = LayoutInflater.from(context)
view = layoutInflater.inflate(R.layout.list_view_item,
parent, false)
vh = ViewHolder(view)
view.tag = vh
} else {
view = convertView
vh = view.tag as ViewHolder
}
vh.tvTitle.text = listModelArrayList[position].title
vh.tvContent.text = listModelArrayList[position].content
return view
}
class ListViewModel{
var id: Int? = null
var title: String? = null
var content: String? = null
<ListView
android:id="@+id/sample_listVw"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
ListView Item Code:
<TextView
android:id="@+id/tvTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:text="TextView"
android:textColor="?android:attr/colorForeground"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvContent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="@+id/tvTitle"
app:layout_constraintStart_toStartOf="@+id/tvTitle"
app:layout_constraintTop_toBottomOf="@+id/tvTitle" />
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v7.widget.Recycle
rView>
package com.bett.kotlinrecyclerview
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import bett.com.kotlinlistview.dtos.UserDto
import com.bett.kotlinrecyclerview.adapters.UsersAdapter
recyclerView = findViewById(R.id.recyclerView)
var adapter = UsersAdapter(generateData())
val layoutManager = LinearLayoutManager(applicationContext)
recyclerView?.layoutManager = layoutManager
recyclerView?.itemAnimator = DefaultItemAnimator()
recyclerView?.adapter = adapter
adapter.notifyDataSetChanged()
}
private fun generateData(): ArrayList<UserDto> {
var result = ArrayList<UserDto>()
for (i in 0..9) {
var user: UserDto = UserDto("Bett", "Awesome work ;)")
result.add(user)
}
return result
}
implementation 'com.android.support:recyclerview-v7:26.0.1'