2010-11-15 40 views
0

任何人都可以建議如何在瀏覽器圖標,電子郵件圖標和聯繫人圖標上點擊應該分別導致android瀏覽器,電子郵件和聯繫人應用程序的圖標列表......現在我已經完成了點擊按鈕。現在我想的圖標(帶圖像和文字),而不是按鈕...我如何在我的android應用程序中有圖標列表;

回答

0

我以爲你想要ImageButton,點擊你想打開特定的應用程序/瀏覽器/聯繫人列表。

的ImageButton - 顯示一個按鈕的圖像(而不是文字),可以由用戶按下或點擊

<ImageButton 
    android:id="@+id/ImageButton01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/icon/> 

如果你想要的ImageButton與背景按鈕,然後設置android:background屬性,如下:

<ImageButton 
    android:id="@+id/ImageButton01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/icon" 
    android:background="@drawable/background_image"/> 
+0

嗨,你可以請讓我知道如何創建ImageButton – manju 2010-11-15 11:29:34

+1

感謝帕雷什我發現有關android的開發網站imagebutton,再次感謝... – manju 2010-11-15 11:31:51

+0

@manju很高興知道你的這種答覆! !享受 – 2010-11-15 11:35:51

1

沒有小部件圖標。 你可以使用LinearLayoutImageViewTextView自己做。

的XML應該是這樣的:

<LinearLayout android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <ImageView android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/your_image"/> 

    <TextView android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/your_icon_text"/> 

</LinearLayout> 
+0

嗨,謝謝..我想要圖像視圖大小相似的圖標和模擬器屏幕的角落... – manju 2010-11-15 11:27:33

0

您可以使用Android圖像按鈕,並設置其屬性「可點擊= true」,並做其click事件偵聽器

+1

非常感謝你Shaireen – manju 2010-11-15 11:33:14

+0

它工作謝謝.. – manju 2010-11-17 12:23:43

0

如果你所需要的工作想要在您的按鈕中使用文字,我這樣做的方式是創建一個9補丁,因此我可以使用填充和可伸縮區域定義文本的位置。然後遵循與已經提到的自定義按鈕相同的說明,但使用標準按鈕而不是圖像按鈕。

+0

嗨,感謝TenFour你可以給代碼或任何參考網站9補丁.... – manju 2010-11-16 04:38:59

相關問題