Subject: Smart Phone Application Development Question: Explore the dictionary project. Add various word and its meaning. Try
Question:
Subject: Smart Phone Application Development
Question: Explore the dictionary project. Add various word and its meaning. Try to use constraint layout instead of linear layout in view?
For WordDataModel.java class,
packagecom.example.dictionary; importjava.util.ArrayList; importjava.util.List; public classWordDataModel { publicStringenglish; publicStringbangla; publicWordDataModel(String english, String bangla) { this.english= english; this.bangla= bangla; } publicString getEnglish() { returnenglish; } publicWordDataModel setEnglish(String english) { this.english= english; return this; } publicString getBangla() { returnbangla; } publicWordDataModel setBangla(String bangla) { this.bangla= bangla; return this; } public staticList
For MainActivity.java class,
packagecom.example.dictionary; importandroidx.appcompat.app.AppCompatActivity; importandroidx.recyclerview.widget.DefaultItemAnimator; importandroidx.recyclerview.widget.DividerItemDecoration; importandroidx.recyclerview.widget.LinearLayoutManager; importandroidx.recyclerview.widget.RecyclerView; importandroid.os.Bundle; importandroid.util.Log; importjava.util.List; public classMainActivityextendsAppCompatActivity { private finalStringLOG_TAG="DICTIONARY"; @Override protected voidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView wordsHolder = findViewById(R.id.wordsHolder); List
For Dictionary.adapter.java class,
packagecom.example.dictionary; importandroid.content.Context; importandroid.view.LayoutInflater; importandroid.view.View; importandroid.view.ViewGroup; importandroid.widget.TextView; importandroidx.recyclerview.widget.RecyclerView; importjava.util.List; public classDictionaryAdapterextends RecyclerView.Adapter
For activity_main.xml,
xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/wordsHolder" 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"/> androidx.constraintlayout.widget.ConstraintLayout>
For dictionary_item.xml,
xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/englishWord" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="English Word" android:textSize="34sp"/> <TextView android:id="@+id/banglaWord" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:paddingBottom="15dp" android:text="Bangla Word" android:textSize="34sp"/> LinearLayout>
For AndroidManifest.xml, xml version="1.0"encoding="utf-8"?> <manifestxmlns:android="http://schemas.android.com/apk/res/android" package="com.example.dictionary"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" a.."@style/Theme.Dictionary"> <activity android:name=".MainActivity" android:exported="true"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> intent-filter> activity> application> manifest>
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts