Android -Disable all other option when clicked on any other - android-studio

I am making an quiz app. I have 4 options. When i click on button 1 all other 3 buttons should be disabled and when i click on next button all options should be enabled.

Create a function like below to enable or disable button. call this function on the click listener of button1 isEnableButtons(false) and for next button call isEnableButtons(true)
private void isEnableButtons(boolean value){
mButton2.setEnabled(value);
mButton3.setEnabled(value);
mButton4.setEnabled(value);
}

Related

How to Dismiss the created Alert in listview item button click in Xamarin.android

AlertDialog.Builder alert = new AlertDialog.Builder(m_context);
View layout = m_context.LayoutInflater.Inflate(Resource.Layout.editLabelPopupLayout, null);
alert.SetView(layout);
I alert.SetPositiveButton("OK", CancelAction); //cancel action is a method to dismiss
dialog.Show();
I have created BaseAdapter to inflate the listview items .In item there is a button to show AlertBox with EditText. It shows correctly , but in that PositiveButton click , I have assigned to dismiss the Popup .But it dismisses after the number of times click(position of listview item) .
How to Dismiss the Popup?
THANKS IN ADVANCE !
I have tried inflating a Layout from the listview item button , and i tried ti dismiss using the Popup button using Dismiss() .
But it wont.
Last listview item (Recently added) need one click to dismiss the popup .one before that requires two clicks to dismiss the popup .and it goes on.

React Native Navigation: how to disable backbutton on modals?

I've a login modal opened using showModal().
It has no navbar buttons, so ios users cannot close this modal.
Problem: Actually Android users can use hardware back button to close the login modal.
In my login modal I tried to add
BackHandler.addEventListener('hardwareBackPress', function() {
return true;
}
to disallow backbutton on Android, but it simply doesn't works.
I did this because I read what follows on official RN guide:
Android: Detect hardware back button presses, and programmatically invoke the default back button functionality to exit the app if there are no listeners or if none of the listeners return true.
Adding a console.log into this function I see the event fired on 'normal' screens but NOT when I've a modal showed !
What am i doing wrong?
Overriding hardware back button is possible using overrideBackPress property as described here
You can handle the back press in your component:
onNavigatorEvent(event) {
if (event.id === 'backPress') {
//Do your thing
}
}

C++ Windows form application Switching between forms

So i have my main form and i open a second form using this code
this->Hide();
Form2^ dlg=gcnew Form2();
dlg->ShowDialog();
how do i go back from the second form to the main one?
In the dialog code set the DialogResult property, this will close the dialog and return to the main form, ShowDialog will return the DialogResult value you set.
Alternatively you can have a button on the dialog that has a DialogResult property set and then clicking the button will close the dialog and return the value associated with the button.

dlg.DoModal() is making the dialog box modal to the application and not to the previous dialogue box

if (IDOK == dlg.DoModal())
{
csFile = dlg.GetPathName();
return (LPCTSTR)csFile;
}
return NULL;
I have a desktop application and in this I have a dialog box. When I click on open button in this dialog box another open dialog box should pop up. Once this open dialogue box is displayed I am able to again go to the previous dialogue box and click on open. So second instance of open dialog box is displayed. I can do this many times. The open dialog box is modal to the whole application and not to the previous dialog box. Can anyone help me with this? As per design once open dialog box is displayed nothing else should be active till this is closed.
The standard wizard-generated constructor for the dialog box contains an optional constructor-parameter where you can specify the parent window:
class CMyOpenDialog : public CDialog
{
// Construction
public:
CMyOpenDialog(CWnd* pParent = NULL); // standard constructor
...
When you invoke this second dialog from your dialog, supply the parent, like
CMyOpenDialogdlg(this);

Updating toolbar button state MFC

I have a dialog in MFC application, which is having menu-bar. Now I have created a toolbar in that dialog using the same command ID which is in the menu-bar.
I use to update the menu-item's state and makes it enable/disable as per some check in ON_UPDATE_COMMAND_UI, When I clicks on the menu. But for toolbar I didn't gets these calls to update it's state, If it should be enabled/disabled.
Moreover I didn't have any notification when the test fails and I to disable the item.
Is there some alternative for doing this?
Thanks
call to ON_UPDATE_COMMAND_UI is only coming when I click on the toolbar button.
Use MFC in a dialog can be frustrating.
I suggest you disable the toolbar button directly when changing state to the variable that will enable / disable the menu:
void CtestDlg::OnBnClickedButton_DisableSomeControls()
{
command_menu_1 = !command_menu_1;
m_ToolBar.GetToolBarCtrl().EnableButton(ID_COMMAND_TEST, command_menu_1);
}
is not very elegant, but it works!

Resources