mrana
mrana

Reputation: 67

How to show the name of the widget on a TextView?

Let me explain: I need to show the name of any building block either it is imagebutton, edittext in my textview field depending upon which of above written will be hover over by the user. So that my textview could behave like some dynamic display plate.

Any help will highly be appreciated.

mrana..

Upvotes: 0

Views: 86

Answers (2)

Rajesh Kolappakam
Rajesh Kolappakam

Reputation: 2125

Since this is a touch device, "hovering" will not be possible. One solution is to show the name on when long-press. See this solution https://stackoverflow.com/a/4433441/1227692

EDI: Thanks Frank and mrana for pointing out. I agree and take back my comment.

Upvotes: 1

Frank Sposaro
Frank Sposaro

Reputation: 8531

So something that you can do. Since there it no "setText" for imageviews, you can do something like

String name = "imageview";
imageView.setTag(name);

Then in your onFocusedChangedListener call the following method

void displayInTextView(View selectedView) {
    String viewName = (String) selectedView.getTag();
    mDisplayText.setText(viewName);
}

Upvotes: 2

Related Questions