<activity android:configChanges="orientation|screenSize" android:icon="#drawable/a512" android:label="KMI" android:theme="#style/MainTheme" android:name="md5ce51fed3f5ce2f508bfc10049c6540f6.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
the problem seems to be with configchanges part here. Is there any way to fix it? I did try to remove it, but it just comes back and the same error comes up.
[Activity(Label = "KMI", Icon = "#drawable/a512", Theme = "#style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
If you are using Xamarin, it is better that you provide these in the Activity Attribute of your Activity class file. Assume that you would like to do this in your MainActivity file. Then what you can do is something like below:
[Activity(ScreenOrientation = ScreenOrientation.Portrait, Theme = "#style/MyTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global:: Xamarin.Forms.Platform.Android.FormsAppCompatActivity
Related
I am creating my first Xamarin Forms cross-platform application. I am in the process of creating a splash screen using the native platform code for each OS.
My Android splash screen is not displaying. I trace through the application and it hits the correct code, but the page does not display.
My xml file is in the resources\layout folder which renders nicely when I view it. It is called SplashScreen.xml.
Can anyone shed some light as to why the page does not display?
{
[Activity(MainLauncher = true, NoHistory = true)]
public class SplashScreenActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
RequestWindowFeature(WindowFeatures.NoTitle);
base.OnCreate(savedInstanceState);
SetContentView(Droid.Resource.Layout.SplashScreen);
System.Threading.Thread.Sleep(3000);
StartActivity(typeof(MainActivity));
}
public override void OnBackPressed() { }
}
}
Better Approach
In your Resources -> Values -> styles.xml create your splash screen theme.
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="splashscreen" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/splashscreen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
Go to your MainActivity.cs and ensure MainLauncher = true. Ensure no other activity has MainLauncher=true.
In MainActivity.cs change the default theme to the splash screen.
[Activity(Label = "Mobile App", Theme = "#style/splashscreen", Icon = "#drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, LaunchMode = LaunchMode.SingleTop)]
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
In OnCreate, switch your theme with the below code.
protected override void OnCreate(Bundle bundle)
{
base.Window.RequestFeature(WindowFeatures.ActionBar);
// Name of the MainActivity theme you had there before.
// Or you can use global::Android.Resource.Style.ThemeHoloLight
base.SetTheme(Resource.Style.MainTheme);
base.OnCreate(bundle);
...
Please refer this blog.
You should write a theme to load your xml first, like this:
<resources>
<style name="MyTheme.Base" parent="Theme.AppCompat.Light">
</style>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/SplashScreen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
</resources>
Then use that theme in the activity:
[Activity(Theme = "#style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
Here is the document about Splash Screen in Xamarin.Android and there are detailed steps you can follow.
A sample project is also available : splashscreen.
There are 2 places I can change the icon for my xamarin forms android project.
One is in the
.Android > MainActivity.cs
[Activity(Label = "ZammyTestApp", Icon = "#mipmap/icon", Theme = "#style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
and there is also the manifest file.
Which one is the right place
I will suggest you to change the icon from MainActivity. Suppose you have an icon activity definition in your MainActivity and then you try to change icon from manifest file, icon would not change because icon activity definition in your Main Activity overrides the manifest.
Why MainActivity overrides the manifest?
If you click here, document states that if you use [Activity] custom attribute, it causes xml fragment to be added to AndroidManifest.xml at compile time.
Click here to see that how the [Activity] attribute helps to produce icon in xml fragment. For example:
[Activity (Label="My App", MainLauncher=true, Icon="#drawable/myicon")]
public class MyActivity : Activity
{
}
This example produces the following xml fragment:
<activity android:icon="#drawable/myicon" android:label="My App"
android:name="md5a7a3c803e481ad8926683588c7e9031b.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And check the accepted answer here in xamarin forums.
How can I write hashMap inside an fxml. I tried like this, but my IDE doesn't recognize the "entry" tag name. This must create a Map<String, Integer>
<FXCollections fx:factory="observableHashMap">
<entry>
<String fx:value="Vandaag" />
<Integer fx:value="1"/>
</entry>
<entry>
<String fx:value="Deze week" />
<Integer fx:value="7"/>
</entry>
<entry>
<String fx:value="Deze maand" />
<Integer fx:value="31"/>
</entry>
</FXCollections>
Defining as
<FXCollections fx:factory="observableHashMap">
<foo>123</foo>
<bar>456</bar>
</FXCollections>
works. However you loose the type safety and may not able to define a space separated key like
<kung foo>123</kung foo>
So defining the map in controller seems more appropriate.
There isn't much about maps in the introduction to FXML. However, you can do something like this: (in fxml)
<Group fx:id="mapWrapper">
<properties Vandaag="1" Deze_week="7" Deze_maand="31" />
</Group>
Then in your controller class you can have:
#FXML
private Group mapWrapper;
private ObservableMap map;
public void initialize() {
// the properties object is backed up by observable hash map
map = mapWrapper.getProperties();
// do something with the map
map.forEach((key, value) -> System.out.println(key + ":" + value));
}
prints the following:
Deze_maand:31
Vandaag:1
Deze_week:7
It probably isn't exactly what you wanted but it works
i created custom-actionmodels.xml
<model name="partInfoPageTabSet" resource="com.ptc.core.ui.navigationRB">
<submodel name="windimTabModel" />
</model>
<model name="windimTabModel" resourceBundle="com.windim.windimRB">
<action name="windimTabAction" type="windim"/>
</model>
custom-actions.xml also
<objecttype name="windim" resourceBundle="com.windim.windimRB">
<action name="windimTabAction" resourceBundle="com.windim.windimRB">
<command windowType="page" url="netmarkets/jsp/part/info.jsp"/>
</action>
</objecttype>
and compiled windimRB.java in /codebase/com/windim
package com.windim;
import wt.util.resource.*;
#RBUUID("com.windim.windimRB")
public final class windimRB extends WTListResourceBundle {
#RBEntry("WindIM")
// #RBComment("Resolving issues")
// #RBArgComment0("Any string...")
public static final String WINDIM_TABMODEL = "object_windimTabModel";
}
and tab does not work.
object_windimTabModel
turned intoto
object.windimTabModel
I'm trying to implement an Action in SWF but I get the same error even in the simplest example.
Error: "java.lang.IllegalStateException: No actions were executed, thus I cannot execute any state transition"
import org.springframework.webflow.execution.Action;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;
public class HelloAction implements Action {
#Override
public Event execute(RequestContext rc) throws Exception {
return new Event(this, "success");
}
I've declared the bean.
<bean id="helloAction" class="app.action.HelloAction"/>
And in flow.xml..
<action-state id="intermedio">
<action bean="helloAction"/>
<transition on="success" to="fin"/>
</action-state>
<end-state id="fin" view="final" />
It works fine if I don't use "HelloAction". But if I want to use Action in SWF, I always get the previous error.
Is something else needed?
Thanks in advance.
<action-state id="intermedio">
<evaluate expression="helloAction.execute()">
<transition on="success" to="fin"/>
</action-state>