获取视图文本(按钮) [英] Get text of view (button)

查看:176
本文介绍了获取视图文本(按钮)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在相对布局中有两列。两栏都有几个带文字的按钮。我想使用加入按钮的手指绘制一条线。以匹配下列为例:

像A ------------------- A。



以上事情完成。现在我想从用户开始画线和结束线的位置获取按钮的文本。在上面的情况下是A。



任何人都可以帮我解决问题。


当用户从手指开始绘制线条时,我想用橙色圆圈显示文字然后当用户停止从手指画线时绿圈的文本。显示在圆圈内的文本只是按钮。



我正在使用onTouchEvent(MotionEvent事件)进行绘图。



我希望现在能够解释我的要求更多



谢谢

解决方案

  public void onClick(View v){

Button b =(Button)v;
String buttonText = b.getText()。toString();
Toast.makeText(getBaseContext(),buttonText,1000).show();
}


I have two column in relative layout. both column have few button with text. I want to draw a line using finger which join the button. Take the example of "match the following"
like A ------------------- A.

Above things are done. Now i want to get the text of button from where user start drawing the line and end the line. In above case is "A".

Could any one please help me out.

I want to get the text with Orange circle when user start drawing the line from finger and then text of the green circle when user stop the line draw from finger. Text showing inside the circle are button only.

I am using onTouchEvent(MotionEvent event) for drawing line.

I hope now i am able to explain my requirement more

Thanks

解决方案

    public void onClick(View v) {

        Button b = (Button)v;
        String buttonText = b.getText().toString();
        Toast.makeText(getBaseContext(), buttonText , 1000).show();
    }

这篇关于获取视图文本(按钮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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