1 year ago

#389288

test-img

Daniel Traslavina

How to add custom layout elements to listView in Android Studio

I have this custom layout element

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:padding="10dp"
android:layout_height="wrap_content"
android:layout_width="match_parent">


<EditText
    android:id="@+id/firstEdit"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:gravity="center"
    android:textSize="20sp"
    android:textColor="@color/purple_200"
    android:layout_weight="0.4"/>

<EditText
    android:id="@+id/secondEdit"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="0.3"
    android:gravity="center"
    android:textSize="20sp"
    android:inputType="numberDecimal"/>

<EditText
    android:id="@+id/thirdEdit"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="0.3"
    android:gravity="center"
    android:textSize="20sp"
    android:inputType="numberDecimal"/>

<ImageButton
    android:id="@+id/imgBtn"
    android:backgroundTint="@color/purple_500"
    android:src="@drawable/ic_baseline_control_point_24"
    android:layout_width="30dp"
    android:layout_height="match_parent"
    android:layout_weight="0.1"
    android:checked="false"
    android:clickable="false"
    android:gravity="center" />

It's basically just three edit texts and a button, is there a way to create a list and progressively add elements of this type to it? I've seen ways of doing it with a cursorAdapter but I believe those can only be used for sqlLite queries and such, but I want to start the list with just one element and let the button add extra elements of the same type.

java

android

mobile

0 Answers

Your Answer

Accepted video resources