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

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.

Related

Adding Image button after Add button is clicked (Android Studio Java)

Is it possible in Android studio to produce an Image Button after I clicked a button like Add Button. If yes, how? I want to make an attendance app wherein if the user clicks Add Class an image button will appear
We have no idea of which layout of you are using as the parent. But, for the best results of my answer, linear layout is advised.
The thing you are trying to achieve is trying to create dynamic elements.
For this, you can create an instance of the ImageButton class and then add it to you layout. This can be dont as follows:
//inside onclick of the add button
ImageButton newView = new ImageButton(context);
parentView.addView(newView);
You can add customisations to the view before adding it to the view.

Add Nav buttons on left hand side of Navigation bar

I have a Xamarin page with a Navigation bar at the top.
I keep changing the views on the page with some button clicks, but the page remains the same.
What I need is, when I load a new view (say View A) on this page, I want to add a Back button on the top Nav bar of the page.
I saw some forums where they are using Custom page renderers to add Back button.
But here, the page remains the same. Only the view changes. So, I guess I need to use the custom view renderer to add the Navigation button.
How can I achieve this, as NavigationController which I need to add a Nav button is present in Page renderers, not View renderers.
I need some help.
Thanks
UIBarButtonItem customButton = new UIBarButtonItem(
UIImage.FromFile("Image/image.png"),
UIBarButtonItemStyle.Plain,
(sender, e) =>{
//InitView
});
NavigationItem.LeftBarButtonItem = customButton;
this.NavigationItem.LeftBarButtonItem.TintColor = UIColor.Orange;

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);

Why no back button on DateElement picker?

This walkthrough for MT.D shows a back button on the UIDatePicker that appears when a DateElement is tapped. I'm in an iPad app, and using an MT.D DialogViewController as a subview in an overall UIView. When the date picker slides up I just get the black background with no way to dismiss the picker (no nav bar w/ back button). Same problem exists for the radio group picker. Is this because the dialog view controller is being used as a subview? Any ideas how I might get a nav bar up with a back button using the built-in picker logic?
You must use the DialogViewController as a child element of a UINavigationController to get the back button. On iPad, you can embed the UINavigationController in a UIPopoverController.
Adding the view of a controller into the view of another controller is not considered good design on iOS and won't result in the behavior you expect.

BackButtonBarItem not working properly in iphone

I implemented the following code to show the navigation bar with a backbuttonbaritem.
[mapNavigationItem setTitle:#"Tracking"];
[mapNavigationItem setRightBarButtonItem:nil];
[mapNavigationItem setLeftBarButtonItem:nil];
UIBarButtonItem *stopTrackingBarButton = [[UIBarButtonItem alloc] initWithTitle:#"Stop Tracking" style:UIBarButtonItemStylePlain target:nil action:#selector(stopTracking)];
[mapNavigationItem setBackBarButtonItem:stopTrackingBarButton];
[mapNavigationBar pushNavigationItem:mapNavigationItem animated:NO];
[stopTrackingBarButton release];
The stopTracking button is displayed on the screen, but no title is displayed. When i click on the stopTracking button, it disappears and then shows the title.
Could someone please tell me whats happening??
Ok i think i wasnt clear enough,
I have a mapview with buttons in the tab bar, when the app starts the navigation bar shows 2 buttons, when i click on one of the Tab bar items, it should clear the navigation bar buttons and add a back button bar button item only. I am successful upto this stage.
But when i click on the BackBar button item, it disappears, and does not perform the action assigned to it.
FYI:
IBOutlet UINavigationBar *mapNavigationBar;
IBOutlet UINavigationItem *mapNavigationItem;
If you want to use a different title for your back button than the previous navigation title, then you need to change it just before pushing the new view controller and change it back again after popping it.
So something like:
self.navigationItem.title = #"Stop Tracking";
[self.navigationController pushViewController:mapNavigationItem animated:NO];
and in this class's viewWillAppear
self.navigationItem.title = #"Tracking";
Edit:
If you are not using the backbarbutton for taking the navigation controller back then dont set it as a backBarButton simply set it as left barButton item.
Plus it also seems like you are using same navigation bar for both tabs. not a good idea. Load both tab views from different viewcontrollers and add two different navigation bars to those views.

Resources