Does anyone know of any sample gluon-mobile projects with a DropdownButton control? I'm trying to create a View with a DropdownButton in the center, but after I select an option the control freezes and won't let me select any other menu items. I'm using Gluon Charm 4.0.1 and testing with "gradle run" (Desktop mode). DropdownButton seems like such a simple control I hope there's a simple fix. Thanks in advance for any help.
Sample code:
package org.bytabit.ft.fxui.client;
import com.gluonhq.charm.glisten.control.DropdownButton;
import com.gluonhq.charm.glisten.mvc.View;
import javafx.scene.control.MenuItem;
public class MyView extends View {
public MyView(String name) {
super(name);
DropdownButton dropdownButton = new DropdownButton();
MenuItem menuItem = new MenuItem("Choice 1");
dropdownButton.getItems().addAll(menuItem, new MenuItem("Choice 2"), new MenuItem("Choice 3"), new MenuItem("Choice 4"));
dropdownButton.setSelectedItem(menuItem);
setCenter(dropdownButton);
}
}
This problem looks like it was fixed in the latest version of the Charm library. I just had to update from Charm 4.0.1 to 4.2.0. Thanks Gluon team!
dependencies {
compile "com.gluonhq:charm:4.2.0"
...
Charm 4.2.0 release announcement here.
Related
I am kind of new to Xamarin development. I tried to change the back button behavior with a binding command, but that didn't seem to work. This is the code for the view:
<Shell.BackButtonBehavior>
<BackButtonBehavior Command="{Binding GoBack}"/>
</Shell.BackButtonBehavior>
And this is the code for the view model:
public CreatePasswordVM()
{
_goBack = new Command(GoBackButton);
}
private ICommand _goBack;
public ICommand GoBack
{
get { return _goBack; }
}
public async void GoBackButton()
{
await Shell.Current.GoToAsync("../..");
}
When I pressed the back button, the method "GoBackButton" didn't call. I want to mention that on Android works.
Shell BackButtonBehavior command binding not working in UWP
Derive from Xamarin Form source code. BackButtonBehavior has not implemented for UWP platform, we could find Android and IOS implementation here and here. But for uwp there is not such tracker and there is not such value in the UWP ShellRenderer. For this scenario, we suggest your post new feature request in the Xamarin Forms github.
I have a xamarin project and my main purpose is creating a widget by using activity_main layout and my activity main layout includes tabbed pages such as Tab1 , Tab2 and Tab3 . That is why i want to show them on widget . According to my researches i need some xml file to create a widget on android . My xml file like this.
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dip"
android:minHeight="72dip"
android:resizeMode="horizontal"
android:minResizeWidth="144dip"
android:updatePeriodMillis="86400000"
android:initialLayout="#layout/activity_main"/>
I added activity_main as a initialLayout and i did some arrangement in the bag. My appwidget class like this .
[BroadcastReceiver(Label = "Widget")]
[IntentFilter(new string[] { "android.appwidget.action.APPWIDGET_UPDATE" })]
[MetaData("android.appwidget.provider", Resource = "#xml/widget_word")]
class AppWidget : AppWidgetProvider
{
public override void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{
context.StartService(new Intent(context, typeof(UpdateService)));
}
}
My updateService like this .
public override void OnStart(Intent intent, int startId)
{
// Build the widget update for today
RemoteViews updateViews = buildUpdate(this);
// Push update for this widget to the home screen
ComponentName thisWidget = new ComponentName(this, Java.Lang.Class.FromType(typeof(AppWidget)).Name);
AppWidgetManager manager = AppWidgetManager.GetInstance(this);
manager.UpdateAppWidget(thisWidget, updateViews);
}
public override IBinder OnBind(Intent intent)
{
throw new NotImplementedException();
}
public RemoteViews buildUpdate(Context context)
{
// Build an update that holds the updated widget contents
var updateViews = new RemoteViews(context.PackageName, Resource.Layout.activity_main);
return updateViews;
}
I am using fragments to display tab1 , tab2 , tab3 . If I add fragment axml file to the initialLayout it works fine . But it shows only tab1 . I feel like i should use activity_main to display 3 tabs on widget. Please help !
You cannot use bottomNavigationView in the appwidget,
If you set it you will get follow error.
Creating the App Widget layout is simple if you're familiar with Layouts. However, you must be aware that App Widget layouts are based on RemoteViews, which do not support every kind of layout or view widget.
A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:
FrameLayout
LinearLayout
RelativeLayout
GridLayout
And the following widget classes:
AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView
ViewFlipper
ListView
GridView
StackView
AdapterViewFlipper
Descendants of these classes are not supported.
Here is Google article about it.
https://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
I am trying to change the color of a toolbar in a Xamarin.Forms application. I used this to change the color:
MainPage = new NavigationPage(new StartPage())
{
BarBackgroundColor = Color.FromHex("#15315A"),
BarTextColor = Color.FromHex("#F3F9F5")
};
This works successfully on iOS, but on Android the Toolbar is just white. I tried to change the styles colors, and defined a Toolbar.axml with no luck either. I posted the pictures below of what I am seeing. Anyone know what I could be doing wrong?
There was a fairly good answer on this post on the xamarin developer forums. Basically there's a couple of options to get this to work, these are:
An Appearance which works globally.
Or using a custom renderer.
[assembly: ExportRenderer(typeof(TabbedPage), typeof(TabbedPageCustom))]
namespace MobileCRM.iOS
{
public class TabbedPageCustom : TabbedRenderer
{
public TabbedPageCustom ()
{
TabBar.TintColor = MonoTouch.UIKit.UIColor.Black;
TabBar.BarTintColor = MonoTouch.UIKit.UIColor.Blue;
TabBar.BackgroundColor = MonoTouch.UIKit.UIColor.Green;
}
}
}
How can I present a modal view on iOS using MvvmCross?
Using Xamarin Studio on iOS and the MvvmCross NuGet version 4.2.2, none of the MvxModalSupportTouchViewPresenter, MvxModalNavSupportTouchViewPresenter or IMvxModalTouchView are even available.
Does the ViewModel even need to know about the fact that a particular view is presented as a modal view on iOS?
MvvmCross is a strong Page navigation framework. Default navigation using ShowViewModel<AViewModel> will use the stack metaphor: one on top of another on Android, slide atop each other on iOS, and use < on either platform to go back.
You can tell the ViewPresenter that a given view is modal by giving it a hint, in the form of an interface marker, by adopting IMvxModalIosView.
At the View Level
Adopt the IMvxModalIosView protocol:
public partial class AView : MvxViewController, IMvxModalIosView
At the AppDelegate Level
Replace var setup = new Setup(this, Window) by:
var presenter = new MvxModalSupportIosViewPresenter(this, Window);
var setup = new Setup(this, presenter);
setup.Initialize();
At the ViewModel Level
No change required. The ViewModel is actually not made aware of the modal presentation. Invoke:
ShowViewModel<AViewModel> // May be modal on certain platforms
To close a Page and go back to the previous one, regardless of your presentation style, use Close(this) on that very ViewModel. This will close a modal dialog, or pop a pushed view. A complete, bindable ICommand may look like this:
public ICommand BackCommand {
get { return new MvxCommand(() => Close(this)); }
}
Notes: In MvvmCross 4.2.2, Touch has been renamed iOS, so IMvxModalTouchView is now IMvxModalIosView. The new using are:
using MvvmCross.iOS.Platform;
using MvvmCross.iOS.Views.Presenters;
Using MvvmCross 5.5.2 all I had to get a modal was to add the following MvxModalPresentation attribute to my iOS view:
[Register("ExampleModalView")]
[MvxModalPresentation(
ModalPresentationStyle = UIModalPresentationStyle.PageSheet,
ModalTransitionStyle = UIModalTransitionStyle.CoverVertical
)]
public class ExampleModalView : MvxViewController
{
public ExampleModalView() {
}
...
}
Launching the modal is simple with the IMvxNavigationService service
await _navigationService.Navigate<ExampleModalViewModel>();
ExampleModalViewModel just needs to be a plain MvvmCross view model inheriting from MvxViewModel.
A useful reference for this is ModalView.cs in the iOS playground project: https://github.com/MvvmCross/MvvmCross/blob/develop/TestProjects/Playground/Playground.iOS/Views/ModalView.cs#L12
Is there a way to have a SWT buuton with both image and text in a view? I have tried embedding Swings in SWT and the view looks exactly as I want, but when there is an operation going on, this view doesnot load till it gets over. This makes my perspective look unstable. Please help.
What OS are you using? On Windows XP/Vista/Windows 7, GTK+ and OSX you can just set the text and the image. E.g.
public class ButtonView extends ViewPart
{
private Button m_button;
public void createPartControl(Composite parent)
{
m_button = new Button(parent, SWT.NONE);
m_button.setText("My Button");
m_button.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
}
public void setFocus()
{
m_button.setFocus();
}
}