I have a layout that contains 5 buttons which must display one particular dialogbox on clicking any of the buttons.
I assigned one id to the buttons and set an onClick listener to it.
surprisingly, only the first button on the layout displays the dialogbox and others do not.
how can i make all of them to display that particular dialog because i don't want to create different dialog for each button.
Please use a class to assign the attribute. Multiple buttons cannot have the same id.
Related
I have an activity where I have a few main buttons which should be displayed all the time, and I have for every main button a few sub-buttons. The sub-buttons shall be displayed when I click on one main-button.
enter image description here
They are like titles: There are main titles and every main title has got a few sub titles. But the sub-titles should only be displayed when I click on the button with the main title. So when I dont click, only the main buttons shall be seen, not the subbuttons.
How do I realize that? Or is there a godd tutorial for that?
Inside of an View.OnClickListener(), use the following code to make a button invisible:
b.setVisibility(View.GONE);
And to show it:
b.setVisibility(View.VISIBLE);
i want to create a page ,in such a way that a list should come in which first two columns,shows product name and its cost,and the third column should be an edit text to fill quantity.moreover i need three buttons at the bottom of the page.i am a newbie t android programming,plz help
Create a RelativeLayout that contains 2 layouts:
TableLayout for the first requirement.
Another RelativeLayout for keeping buttons at the bottom:
For 3 buttons u set the property android:layout_alignParentBottom="true".
For the 1st button u give android:layout_alignParentLeft="true"
and the 2nd button and 3rd buttons u give android:toRightOf="" property.
You will need to use custom Listiview for this pupose. Your mainview will contain a listview and the 3 buttons at the bottoms as you want.
Checkout following example for custom listview
Custom Listview
I'm developing a SWT app and in one particular form there are 14 pairs of Yes-No radio buttons. Each of these pairs have a text box associated with them. So if a user selects Yes, the associated textbox should be editable else uneditable. I find writing 28 listeners for the radio buttons really daunting. Since the radio buttons have nothing much to do than just rendering the textbox editable/uneditable I was hoping if there were some generic type of listeners in SWT that would be applicable to a set of radio buttons specified in an array or like that. Are there any frameworks or shall I have to write individual listeners?
Edit
I'm trying to fire an event only when the radio button is selected
rdoExperience.addListener(SWT.CHECK, new RadioButtonSelection(
txtExperience));
but SWT.CHECK is causing the event to be fired on mouse hover over radio button too. I've tried using SWT.SELECTED too but it's not working either and I can't find other suitable SWT constants. W;hat should I use?
Good point. Sorry I don't know such thing.
However, you create one yourself: Instead of writing an anonymous listener for every button, you could write one - say MyButtonListener - and give it the button text box as an argument. Than you instantiate MyButtonListener with the appropriate text box as an argument. Than in the Listeners appropriate callback method you enable or disable the text box.
Edit: My bad. Of course I meant you could give it your text box like radioBtn.addListener(SWT.SELECTED, new MyButtonListener(textfield1));
You could create one SelectionListener and add it to each of the radio buttons. Then you can ascertain which button was pressed from the selection event and map that to a text box. For the mapping you could use an array or hashtable.
Im using GXT 2.1.1, I want to to pass widget values from one tab to another tab.For Example I have created two tabs, the first tab displays all the information of students
in a grid with name, date of join, course selected .... and in other tab i want to
display the student information. When ever a user selects the student from the
grid then that should take him to the next tab with all the details of that particular
student.
Add a listener to the grid (row click) or add a "View" button as one of the columns and add a clickListener to it. In the listener, get the student's id and call a method on the second tab to display the details. Then simply call
tabPanel.setSelection(secondTab);
// tabPanel instance of TabPanel
// secondTab instance of TabItem
This should do it.
This is my first question at stackoverflow :-). However, I've started to Android programming some weeks ago and now I have get into a problem that I will describe below.
Problem:
I have a background-image for the whole screen. Inside this LinearLayout I have another LinearLayout with Buttons inside. How can I (without to start a new activity) load another buttons and make the first buttons disappear. The Buttons have a drawable background-image assigned to the specific button.
Like: I have a menu; play, options and quit. When I for example click on Options, the Options should load, and the play-button, options-button and quit-button should disappear.
All I want to become is to remain the background-image without to create a new activity and always can load a bunch of new buttons depending on the button that was clicked on.
For now I have created a new activity for the new buttons that should appear for example: Exit -> Do you want to Exit? Yes or no., then I also have done so the new acitivty loads another xml-layout-resource file, with the same background as before. This is what I want to change to a smoother resolution.
Make two buttons with your second layout. use button1.setVisibility(View.GONE) method to set the visibility of the button. check this link