Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get text of view (button)

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.

enter image description here

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

like image 705
itin Avatar asked Nov 28 '13 10:11

itin


2 Answers

    public void onClick(View v) {

        Button b = (Button)v;
        String buttonText = b.getText().toString();
        Toast.makeText(getBaseContext(), buttonText , 1000).show();
    }
like image 86
Looking Forward Avatar answered Sep 21 '22 12:09

Looking Forward


For example, if the View contains text, use this:

( (TextView) view ).getText().toString();

where view is being cast to TextView.

like image 26
Moz Avatar answered Sep 19 '22 12:09

Moz