auto updating list widget
This commit is contained in:
BIN
app/src/main/res/drawable/widget_list_preview.png
Normal file
BIN
app/src/main/res/drawable/widget_list_preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
26
app/src/main/res/layout/widget_list.xml
Normal file
26
app/src/main/res/layout/widget_list.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="4dp">
|
||||
|
||||
<!-- ListView to be shown on widget -->
|
||||
<ListView
|
||||
android:dividerHeight="4dp"
|
||||
android:id="@+id/list_widget_listView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!-- Empty view is show if list items are empty -->
|
||||
<TextView
|
||||
android:id="@+id/list_widget_empty_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="Empty list"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="20sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
40
app/src/main/res/layout/widget_list_item.xml
Normal file
40
app/src/main/res/layout/widget_list_item.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:background="@android:color/white"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="8dp">
|
||||
|
||||
<TextView
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:id="@+id/widget_list_item_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:textColor="@android:color/black"
|
||||
android:textStyle="bold"
|
||||
tools:text="appname" />
|
||||
|
||||
<TextView
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
|
||||
android:layout_below="@+id/widget_list_item_title"
|
||||
android:id="@+id/widget_list_item_notification"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:textColor="@android:color/black"
|
||||
tools:text="message" />
|
||||
|
||||
<TextView
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
|
||||
android:id="@+id/widget_list_item_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:textColor="@android:color/black"
|
||||
tools:text="date"
|
||||
android:layout_alignTop="@+id/widget_list_item_title"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
10
app/src/main/res/xml/widget_info.xml
Normal file
10
app/src/main/res/xml/widget_info.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="250dp"
|
||||
android:minHeight="110dp"
|
||||
android:updatePeriodMillis="300000"
|
||||
android:previewImage="@drawable/widget_list_preview"
|
||||
android:initialLayout="@layout/widget_list"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen">
|
||||
</appwidget-provider>
|
||||
Reference in New Issue
Block a user