簡體   English   中英

動態更新應用程序小部件的布局

[英]Update app widget layout dynamically

我正在基於voip / sip的應用程序上工作,該應用程序可以通過撥號鍵盤小部件撥打電話,該鍵盤底部有四個按鈕

<?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. 是否不鼓勵我動態切換任何布局元素的可見性? 例如,如果我希望隱藏第四個按鈕,具體取決於存在的任何活動呼叫(我相信這將需要附加一個單獨的專用偵聽器)。
  2. 如果不鼓勵在小部件布局上進行動態更改,那我該怎么做呢?

感謝您的想法和幫助。

我不知道第一個問題的答案,但是為了切換小部件中按鈕的可見性:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM