A week ago I started my todo-list app project and I am learning a lot. I'd like to know about a specific case I couldn't find.
The case: I try to create a "layout-item" of type Linearlayout as a task with specific views inside of it like "Task name, Task description, time, delete button" inside another Linearlayout. But here is the thing, the views of the first Linearlayout are all having a specific position inside of it. I want to keep the positions of the views. How do I create this kind of Layout as an item?
Another short question: When I create this Layout how do I delete it programmatically?
Here you can find my created design and how exactly the "layout-item" (tasks) should look like
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#eeeeee"
android:orientation="horizontal">
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/fira_sans_extra_condensed_semibold"
android:text="Task1"
android:textColor="@color/Task_Name"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/fira_sans_condensed_light"
android:text="Description1 - I want to create a great todo list app :)"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/textView111"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/fira_sans_condensed_light"
android:gravity="end"
android:text="9am"
android:textStyle="bold" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="0dp"
android:layout_height="34dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:background="@null"
android:contentDescription="@string/Delete_Icon"
android:tint="@color/Task_Name"
app:srcCompat="@android:drawable/ic_menu_delete" />
</LinearLayout>
Ahmed is correct, you would use a recycler and create a view that had: Task name, Task description, time, delete button. You then can remove and add items by editing the array that contains your items.
Here is a simple recycler example: Simple Android RecyclerView example
You can use a RecyclerView as described here:
https://developer.android.com/guide/topics/ui/layout/recyclerview
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.