安卓:得到的ImageView的图像源名称将显示在一个TextView [英] Android: Get the image source name of an ImageView to display on a TextView

查看:133
本文介绍了安卓:得到的ImageView的图像源名称将显示在一个TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我是新进android开发,我有麻烦到这一点。我想显示我的的ImageView 上的SRC名称的TextView 当我点击一个特定的形象。 要了解更进一步,这里是我的硬盘code为图像clickListener (希望有人可以帮助我提高我的编码)。

Hi I am new into android development and I am having trouble into this one. I wanted to display the src name of my imageView on a textView when I click a certain Image. To understand much further here is my hardcode for the image clickListener (hope someone can also help me to improve my coding).

    int ctr = 0;
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.play);

        //DECLARE CLICK LISTENERS ON OBJECTS
        ImageView ImageView1 = (ImageView)findViewById(R.id.imageView1);
        ImageView1.setOnClickListener(this);
        ImageView ImageView2 = (ImageView)findViewById(R.id.imageView2);
        ImageView2.setOnClickListener(this);
        ...

public void onClick(View v) {
        //CHANGE TEXT VIEW TEXT BASED ON THE CTR VALUE
        TextView TextView1 =(TextView)findViewById(R.id.textView1); 

        //I WANT TO CHANGE THIS ONE TO DISPLAY SRC INSTEAD OF THE CTR VALUE
        TextView1.setText(Integer.toString(ctr)); 
}

在那里,而不是显示CTR值,我想展示什么形象我点击两个图像我设置之间的src名。我相信这是可能的。谢谢你。

There, instead of displaying the ctr value I wanted to display the src name of whatever image I click between the two images I set. I believe it is possible. Thanks.

推荐答案

嘿KaHel您可以参考以下链接为您的解决方案的点击此处查看答案

Hey KaHel You can refer this link for your solution click here for answer

这篇关于安卓:得到的ImageView的图像源名称将显示在一个TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆