Aalok Sharma
Aalok Sharma

Reputation: 1025

Update app widget layout dynamically

I'm working on a voip/sip based application which is capable of making calls from a dialpad widget which has the four buttons at the bottom

<?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="wrap_content"
    android:orientation="horizontal" >

<ImageButton
    android:id="@+id/ibtn_handsfree"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/selector_dialpad_action_button"
    android:src="@drawable/selector_handsfree" />

<ImageButton
    android:id="@+id/ibtn_headset"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/selector_dialpad_action_button"
    android:src="@drawable/selector_headset" />

<ImageButton
    android:id="@+id/ibtn_copyToDir"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/selector_dialpad_action_button"
    android:src="@drawable/selector_copytodir" />

<ImageButton
    android:id="@+id/ibtn_keyboard"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/selector_dialpad_action_button"
    android:src="@drawable/selector_keyboard" />
<ImageButton 
    android:id="@+id/ibtn_sendkey_widget"
     android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/selector_dialpad_action_button"
    android:src="@drawable/selector_send_key_dialer"
    />
</LinearLayout>
  1. Is it discouraged that I toggle the visibility of any of my layout elements dynamically ? For example if I wish to hide the fourth button, depending on any active call present(which I believe would require an individual and dedicated listener attached).
  2. If the dynamic changes on the widget layout aren't discouraged, how do I go about doing that ?

Appreciate your thoughts and help.

Upvotes: 0

Views: 892

Answers (1)

ozbek
ozbek

Reputation: 21183

I don't know the answer for the first question, but in order to toggle visibility of a button in a widget:

Upvotes: 1

Related Questions