Hi there,
I use Xamarin shell navigation in my project and I have been encountering a particular problem and it happens randomly. This is my scenario. I have a SfButton in my page. The button has to navigate the user to another page using Shell navigation.
The app throws the following message and the app crashes:
System.NotSupportedException: 'Unable to activate instance of type Java.Lang.Runnable from native handle 0x7fd049a434 (key_handle 0x633ca33).'
These are the varieties of messages thrown:
System.NotSupportedException: 'Unable to activate instance of type Java.Lang.Runnable from native handle 0x7fd049a434 (key_handle 0xfc397b6).'
System.NotSupportedException: 'Unable to activate instance of type Java.Lang.Runnable from native handle 0x7fd049a434 (key_handle 0xfc397b6).'
System.NotSupportedException: 'Unable to activate instance of type Java.Lang.Runnable from native handle 0x7fd049a434 (key_handle 0x6a95d0b).'
System.NotSupportedException: 'Unable to activate instance of type Java.Lang.Runnable from native handle 0x7fd049a6c4 (key_handle 0x100f0a).'
I have tried updating to the release 19.2.0.55, yet this is not resolved. An additional information is I tried putting debug points in the target page and ran it several times. The control goes to that page and every time the page loaded successfully. But the moment I removed all debug points, the message starts to show up.
I need a solution immediately, as I'm nearing the release date and I still could not figure out what the problem is. All searches on the Internet leads to this link wherein a similar problem appears to be fixed earlier related to navigation drawer. It would be great if you could help me to resolve this. Please let me know if there is a work around for this in the interim.
Edit: I use Visual Studio 2019
Thanks
Santhosh
|
private async void ShowButton_Clicked(object sender, EventArgs e)
{
const string routePath = nameof(ButtonPage);
await Task.Delay(50);
await Shell.Current.GoToAsync($"{routePath}?UserID=101");
} |
Dear Yuvaraj,
I will try this solution and let you know.
I'm also having a problem with SfListview:
I have a label and Sfcombobox in my SfListview. The source for the combobox is dependent on the label value in each list item. For example, if the label has dr name, then the combobox will have address of the hospitals where he works. It is OK until this part.
The list view has 100 items but only 6 items shows up for the initial display. The problem starts now:
|
Query |
Response |
|
the items loaded in the combobox for the first 6 items repeats for the rest of the items: I resolved it by setting up the ListViewCachingStrategy="CreateNewTemplate" and ItemsSourceChangeCachingStrategy="ClearItems" |
We would like to inform you that the SfListView is completely developed with UI Virtualization(Item recycling) concept and it only creates the element only which are in view on initial loading. While scrolling, we have cache the created elements and recycled it by updating only the BindingContext of the SfListView item. So, we can overcome the reported scenario by binding data for the ComboBox.
You can also refer to our user guidance document to skip reusing items while scrolling in the following link,
|
|
Now the combobox loads up perfectly for all list items. But if i make a selection in the first listitem and scroll down the list and then come back again to the first item, the selection vanishes and it appears as if the user has not selected anything on the combo. |
As we have mentioned above, you can overcome the reported scenario by binding the SfComboBox.SelectedItem to a model property.
Please refer to the following documentation regarding SelectedItem,
|
|
<listView:SfListView x:Name="listView"
ItemsSource="{Binding ContactInfo}"
ItemSpacing="10"
AutoFitMode="Height">
<listView:SfListView.ItemTemplate>
<DataTemplate>
<Frame BorderColor="Blue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<sfCombo:SfComboBox Grid.Row="0" Text="Selecione uma cor"
DataSource="{Binding ContactDetails}"
SelectedItem="{Binding ComboBoxSelectedItem, Mode=TwoWay}"
DisplayMemberPath="ContactName" >
<sfCombo:SfComboBox.ItemTemplate>
<DataTemplate>
<StackLayout >
<Label Text="{Binding ContactName}" VerticalTextAlignment="Center" />
</StackLayout>
</DataTemplate>
</sfCombo:SfComboBox.ItemTemplate>
</sfCombo:SfComboBox>
<Label Grid.Row="1" Text="{Binding Location}"/>
</Grid>
</Frame>
</DataTemplate>
</listView:SfListView.ItemTemplate>
</listView:SfListView> |
Dear Yuvaraj,
First query regarding the java exception: It doesn't work after adding the delay of 50 millisecs. I'm yet to check by increasing the delay further.
Second query about the listview:
I use a Lenovo Tab M10 FHD plus. with Android 10 as minimum version (API 29-Q)
Thanks
Santhosh
|
<sfCombo:SfComboBox Grid.Row="0"
DataSource="{Binding ContactDetails}"
SelectionChanged="SfComboBox_SelectionChanged"
SelectedItem="{Binding ComboBoxSelectedItem, Mode=TwoWay}"
DisplayMemberPath="ContactName" > |
Dear Yuvaraj,
# SfButton: java exception- shell navigate to SfButton page.
I have increased the delay upto 300 milliseconds, the problem still occurs. I could not increase the delay further as there is an evident delay in the loading of the target page. Below is what the button_click event has:
private async void btnDrListBE_Clicked(object sender, EventArgs e)
{
await Task.Delay(300);
await Shell.Current.GoToAsync($"//{nameof(Menu)}/{nameof(BEDrListEntry)}");
}
The button does nothing else. The exception message comes once in 5-10 attempts and does not always occur.
# SfListView query
the combobox is bound to a model. Below is what i'm doing. Value is the property in the model:
Thanks
Santhosh
|
public class ContactInfo_NestedListView : INotifyPropertyChanged
{
private object comboBoxSelectedItem;
public object ComboBoxSelectedItem
{
get { return comboBoxSelectedItem; }
set
{
comboBoxSelectedItem = value;
this.RaisedOnPropertyChanged("ComboBoxSelectedItem");
}
}
...
public event PropertyChangedEventHandler PropertyChanged;
public void RaisedOnPropertyChanged(string _PropertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(_PropertyName));
}
}
} |