I am trying to make my Button displays a text when clicking on it.
I will give you an example of what I meant :
When clicking a button, a text will appear above the button and pointing to that button.
How can this be done?
You can add a TextView programmatically in the onClick event or add it in the xml, set its visibility to gone or invisible and change it in the onClick event
Related
I have a horizontal scroll with set of buttons at the top part of the screen. I want buttons to appear below when one of the buttons above are clicked.
Button button1=new Button(context);
button1.setText("test");
button1.setId(id);
containerlayout.add(button1);
You Must place your buttons on top as well as bottom and then need to set visibility on basis of your click event
How to use radio buttons to decide which button any two buttons should appear where both buttons perform different task? In other words, if i change the radio button a button (normal button) should disappear and another button should take its place which performs another task.
You can use relative layout and place one button on top of the other, then set one of them visibility to "Gone" or "Invisible" when your activity starts or directly in the xml file. Finally add a onCheckedChangelistener to your radio button and change the visibility of the buttons as you need.
Actually i want to change edit text field to check box dynamically on a button click.
initially there is a single button on screen , on clicking a dynamically edit-text is generated, on clicking again the button the edit text converted to checkbox;
I'd suggest you rather use two view elements and show/hide the views.
For example:
Have a LinearLayout that contains 3 elements. The Elements that should be switched, should have the same layout parameters.
A Toggle, a checkbox and a EditTextView.
If the toggle is clicked switch the Visibility for both Views. This is done via mView.setVisibility(View.VISIBLE) or mView.setVisibility(View.INVISIBLE).
how can i make it where a ImageView button when you click it, it will hide 2 pictures and a text box?
then when i click a different image view it will show them again
here's my code (not added any thing)
http://pastebin.com/XTrAy8sX
in the onClickListener for the ImageView, you can use setVisibility() to change the visibility of the other two views
If i click on a button on one layout it should add text view in another layout dynamically again if i click that button same procedure should get repeat.
The question is not very easy to understand, do you mean activities instead of layouts? Or do you have a button in an activity and each time you press it, you want to have an additional text view on the same activity (for example below the button)?