Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我如何在我的android应用程序中拥有图标列表;_Java_Android_Eclipse - Fatal编程技术网

Java 我如何在我的android应用程序中拥有图标列表;

Java 我如何在我的android应用程序中拥有图标列表;,java,android,eclipse,Java,Android,Eclipse,任何人都可以建议我如何在点击这些图标时获得一个图标列表,比如浏览器图标、电子邮件图标和联系人图标,它们应该分别指向android浏览器、电子邮件和联系人应用程序……现在我已经完成了,点击按钮。现在我想要的是图标(带有图像和文本)而不是按钮…请查看: 这将显示您必须将所需图像放入res/drawable/中,然后将其作为按钮加载到应用程序中。我以为您需要,单击您想要打开的特定应用程序/浏览器/联系人列表 ImageButton-显示一个按钮,其中包含用户可以按下或单击的图像(而不是文本) &

任何人都可以建议我如何在点击这些图标时获得一个图标列表,比如浏览器图标、电子邮件图标和联系人图标,它们应该分别指向android浏览器、电子邮件和联系人应用程序……现在我已经完成了,点击按钮。现在我想要的是图标(带有图像和文本)而不是按钮…

请查看:


这将显示您必须将所需图像放入res/drawable/中,然后将其作为按钮加载到应用程序中。

我以为您需要,单击您想要打开的特定应用程序/浏览器/联系人列表

ImageButton-显示一个按钮,其中包含用户可以按下或单击的图像(而不是文本)

  <ImageButton
    android:id="@+id/ImageButton01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/icon/>
没有小部件图标。 您可以使用
线性布局
图像视图和
文本视图
自己完成

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>


您可以使用Android Image Button并设置其属性“Clickable=true”,并在其click event listener上执行所需的操作

如果您希望按钮中包含图像和文本,我的做法是创建一个9补丁,这样我就可以使用填充和可拉伸区域来定义文本的位置。然后按照与前面提到的自定义按钮相同的说明操作,但使用标准按钮,不是图像按钮。

嗨,谢谢..我想要一个图标大小相似的图像视图,在模拟器屏幕的角落…嗨,你能告诉我如何创建ImageButton吗?我使用了你的代码,但出现了运行时错误…我在main.xml中编写了ImageButton代码,并在res/drawable文件夹中保存了一个png图标图像,命名为图标..和调用setonclicklistener();方法。谢谢…我已经使用绝对布局和图像创建了buttons@manju我认为使用“绝对”布局是不可取的,所以请不要这样做,因为在安卓系统中,有不同的分辨率可用,通过使用绝对布局,您可以固定屏幕上的大小,所以它可能不会在所有的手机屏幕上都显示出来。很多我以前不知道。那么我可以使用嵌套的线性布局。我认为线性布局不依赖于手机,它在不同的手机屏幕上工作几乎相同。。。
<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>