如何以编程方式将图像名称设置为图像按钮?

时间:2014-06-12 11:32:07

标签: android

我是android新手。我在我的应用程序中使用了一个imageButton,如下所示:

<LinearLayout >
<ImageButton 
android:layout_gravity="center_horizontal" 
android:id="@id/fund_transfer_btn" 
android:background="@null" 
android:focusable="true" 
android:longClickable="true" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/fund_transfer" 
android:hint="Fund Transfer" android:layout_weight="1.0" />
</LinearLayout >

上面的ImageView有android:src="@drawable/fund_transfer"中提到的默认图像设置。现在这个图像是动态变化,点击ABC按钮就会变为“abc.png”,如:

ImageButton imgbtn=(ImageButton)findViewById(R.id.fund_transfer_btn);
imgbtn.setImageResource(R.drawable.abc);

并点击一些anather按钮将其更改为“xyz.png”:

ImageButton imgbtn=(ImageButton)findViewById(R.id.fund_transfer_btn);
imgbtn.setImageResource(R.drawable.xyz);

现在单击按钮“GetImageName”我想获取当前为此imageButton设置的图像名称并烘烤它。

但无论我搜索到什么都不给我一个图像名称。

所以任何人都可以告诉我,如果有任何方法或方法可以给我一个设置为按钮的图像的名称。

提前谢谢。

0 个答案:

没有答案
相关问题