Just a quick question.
Would it be possible to bring a View (Button) above a Dialog that is currently showing?
Thanks
You could splash another dialog(that contains a button) ontop of the first one.
If you are aiming to get literally just a button and nothing else you'd have to define a custom layout for a dialog that is all transparent except for your button.
No, but you can create it as a custom View on the Dialog, at least (with AlertDialog.Builder.setView()
Related
I have requirement to make this kind of progress bar.
How can I archive this?
You can achieve it by making custom view , you don't have to make fully custom view (i.e extending View) you can modify existing view sub type like Button
im trying to make a to do list in android studio with checkboxes, the idea is to be able to add checkboxes to a linear layout every time i press a button. this is pretty simple but i want to be able to change the checkbox text when i click on it after ive created it.
i tried to make the text box with no text and just place a plain text beside it but i havent found a way to place both of them on the same line of the linear layout. the plain text just appears on the line underneath. i would like to know if theres any way to make a custom component that would make the checkbox text editable when clicked on the text and check the box when clicked on the check box itself that i could place it in the linear layout.
this is the code ive done to add another checkbox to the linear layout:
public void click(View v)
{
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
CheckBox cb=new CheckBox(this);
cb.setLayoutParams(lparams);
cb.setText(t.getText());
this.ll.addView(cb);
}
Check the Checkbox what is it: Checkbox source
Now you know you have a "CompoundButton" , which is a Button if you look at the
source
which is a TextView if you check the source source
The EditText, which is used for editing texts it is a TextView if you check the source
So the parent it is a TextView and in your custom component you must combine the EditText added functions and values to your CheckBox. If you have time and you aren't lazy you can do it for sure, just extend the CheckBox and add the event and handling.
Solution ofered by BAHMAN is fast and simple ( but not enough elegant for me), if you want a quick result you can do that solution or based on that one:
Declare a View named "container" in .xml layout. At your code ( runtime ) first add the Checkbox. On the Click event remove the Checkbox ( if you arenn't added at .xml, but in code you can do it ) and add an Edit text, where you listen the finishing editting event. Then you remove the Edit text and put back the Checkbox. In this case you have not doubled the components and listeners.
Since it is a TODO list, can have many Checkboxes, I would choose the last solution offered by me. If you do an expensive, commercial product, than the first solution offered by me.
Instead of adding a check box to your layout you can add a horizontal linear layout or a custom view extending LinearLayout containing a CheckBox and an EditText at first set visibility of CheckBox to gone when user enters some text in EditText and presses Enter set CheckBox label equal to text of EditText then set visibility of EditText to gone and set Visibility of CheckBox to Visible. Again when a check box is clicked do similar job.
It is better for you to create a custom View (a class extending LinearLayout) and do above job in that class. and every time you need a new check box you can add this custom view to your layout instead of adding check box to your layout.
I have a custom AlertDialog with a bunch of checkboxes. I want to prevent the AlertDialog from closing if none of the checkboxes are selected. Is this possible?
I know I can close momentarily and re-open it, but I would rather not do this as I have some code within the setPositiveButton which I do not want to repeat.
Thanks.
I want to prevent the AlertDialog from closing
Already Posted Answer on SO
OR
Create Custom Dialog to solve the issue.
I'm assuming you're using a custom view, so disable the OK/Cancel buttons at the bottom. Next you'll need to disable the back button:
#Override
public void onBackPressed() {}
The only thing left is to make sure your dialog fills the screen. If the user clicks beside the box on the parent view the dialog will close.
Hi I have a popupwindow on my project.
I want these;
The outside of popupwindow will be touchable and
The popupwindow will be dissmiss when clik on popupwindow.
Actualy I want to use this like
Full screen back button.
I have a full screen button. it makes some components to full screen.
I want to put a popup button full go back from fullscreen view.
How can I do this ?
Sorry for bad english.
Thanks...
I need to display a dialog box which contains radio buttons; and when I select the appropriate radio button, the dialog box should disappear?
Try to use TaskDialog framework. It helps to accomplish just the things you ask for in few lines of code. For your case using Command Links is the best solution.
Radio buttons are possible but not a better solution from usability point of view.
In your radio button listener, use setVisible(false), as discussed in the articles How to Use Radio Buttons and Creating and Showing Simple Dialogs.
I agree with the others that having a "dialog disappear" on radio button click is not a very good UI design. Users generally expect that a "dialog disappears" when they select a button at the bottom (e.g. OK, Cancel, Yes, No, etc.).
In any event, if I am to assume that by "dialog disappears" you mean the window closes, then the way to do that is to call dispose on the dialog.
Also, you may want to consider using JOptionPane.