简体   繁体   中英

how can i have a list of icons in my android app;

can any one suggest how can i have a list of icons like browser icon,email icon and contacts icon upon clicking on those it should lead to android browser,email and contacts apps respectively...right now i have done it, upon clicking buttons. Now i want icons(with image and text) instead of buttons...

Check this out:

http://developer.android.com/resources/tutorials/views/hello-formstuff.html#CustomButton

This will show you had to put the images you want in res/drawable/ and then load them up as buttons in your app.

There is no widget icon. You can do it yourself using a LinearLayout an ImageView and a TextView .

The xml should be something like this:

<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>

I thought you want to have ImageButton , clicking on that you want to open particular application/browser/contact list.

ImageButton - Displays a button with an image (instead of text) that can be pressed or clicked by the user

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

If you wants ImageButton with Background button then set android:background attribute, as below:

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

您可以使用Android Image Button并将其属性设置为“Clickable = true”,并在其click事件侦听器上执行所需的工作

If you want an image and text in your button, the way I do it is create a 9 patch, so I can define where the text will go using the padding and stretchable areas. Then follow the same instructions as for the Custom Button already mentioned, but use a standard button, not an Image Button.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM