ViewTreeLifecycleOwner not found from Dialog - android-jetpack-compose

when I add
<androidx.compose.ui.platform.ComposeView
android:id="#+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
to XML I am getting above error. I tried to update appcompat library but it didnt worked.Anyone have sollution?

Related

Error CS0246 The type or namespace name 'Androidx' could not be found (are you missing a using directive or an assembly reference?)

I am migrating Xamarin.Android application from Andorid 9 to Android 10. I have updated all the support packages to Andoridx packages.
In .axml files after changing the android.support.v7.widget.RecyclerView to androidx.recyclerview.widget.RecyclerView , I am getting "Error CS0246 The type or namespace name 'Androidx' could not be found (are you missing a using directive or an assembly reference?)" in the respective .axml.g.cs file.
Attached screenshot of .axml.g.cs file
I have tried deleting obj, bin folders.
Clean, rebuilt the application. Still not resolved.
Could anyone help me resolving this issue?
Thanks in Advance
activity1.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/backgroundColor">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<include
android:id="#+id/Indicator"
layout="#layout/Indicator" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="#dimen/margin_small"
/>
</FrameLayout>
</LinearLayout>
At first, the namespace is AndroidX.RecyclerView.Widget; not Androidx.
So you can try to add the following code in the .cs file.
using AndroidX.RecyclerView.Widget;
or
private AndroidX.RecyclerView.Widget.RecyclerView _recycler_view;
And then, if it still doesn't work. You can download the nuget package Xamarin.AndroidX.RecyclerView from the package manager.
You should create the android layout file such as:
The cause is the nuget package in your project too old. You can try to use a new package to replace it.

How to fix " Element ....is not allowed " error in layout "activity_main.xml" file

I have created a new android project using Android Studio 3.5.1 using the "Basic Activity" template. But could not get the Design/Text tab rather error messages "Element ...is not allowed here".
The elements are highlighted with red. I do appreciate any help.
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/content_main"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
I have settled it by:
1- Delete "wrapper" folder under ...C:\Users[myUserAcctName].gradle
2- Reload the project and let the Gradle's sync finish (it took 34 minutes).
Then went perfect.
Thanks for those considering an answer.

Xamairin forms : Android.Views.InflateException: <Timeout exceeded getting exception details>

Research a lot about this issue and found the same question, which doesn't solve my problem. so starting a new question.
Xamarin Android: Android.Views.InflateException - Error when loading Layout
Getting Xamairin forms : Android.Views.InflateException: Timeout exceeded getting exception details when loading layout.
Main.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFCDD2"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="#string/hint_name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_email"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="#string/hint_email" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="#string/hint_password" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btn_signup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/btn_sign_up"
android:background="#color/colorPrimary"
android:layout_marginTop="40dp"
android:textColor="#android:color/white" />
</LinearLayout>
I have not used layout:width and layout:height properties in my axml and only using an icon having 4kb size.
Please suggest a solution for this issue, thanks in advance...
Getting Xamairin forms : Android.Views.InflateException: Timeout exceeded getting exception details when loading layout.
There are two things needs to be confirmed before using TextInputLayout:
Please make sure, Xamarin.Android.Support.Design lib is correctly referenced in your Xamarin.Android project. If you are using Xamarin.Forms, it should be referenced by default.
Please make sure the Activity is of type Android.Support.V7.App.AppCompatActivity.
If none of the above things help, please provide a basic demo that can reproduce the problem.
Update:
Upon testing on the project you shared. I found you need to use a Theme.AppCompat theme for your activity, you can do that by following below steps:
Create a styles.xml file under Resources\values\ folder with below codes:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
</resources>
In MainActivity.cs define the Activity attribute to leverage AppTheme like this:
[Activity(Label = "DinexFeedback", MainLauncher = true, Icon = "#drawable/icon",Theme ="#style/AppTheme")]
public class MainActivity : Android.Support.V7.App.AppCompatActivity
{
...
Then the project will run fine.
Unhandled Exception: Android.Views.InflateException:
Make sure the necessary nuget package installed in visual studio.
I used card view in my project, i got this issue becoz i didn't install Xamarin.Android.Support.cardview.
so we should install all support nuget package in order to support all widgets here i use card view.
click on project -> Manage Nuget-> check out the installed pakages, if the package were not installed just search the particular package and then download it.
updated on 10/12/2018
check your layout whether all the layout fields are started with capital letter. for ex : In android we used in small letter but In c# we should use otherwise it throws the inflate view exception.

Bind to current binding context?

I have an item template which is to display a List<IGrouping<string, string>>. In order to do this I need to bind an ItemsSource to the current binding context, in WPF I would do it something like {Binding DataContext} how would I do this in MvvmCross?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
local:MvxBind="Text Key"/> !**IGrouping.Key**!
<Mvx.MvxLinearLayout
android:id="#+id/items"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
local:MvxBind="ItemsSource DataContext" !**This doesn't work, should bind IGrouping as IEnumerable<string>**!
local:MvxItemTemplate="#layout/item_myitem"/>
</LinearLayout>
You can bind to the current source by providing an empty path.
To do this, I find the best syntax is just to use "."
<Mvx.MvxLinearLayout
android:id="#+id/items"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
local:MvxBind="ItemsSource ."
local:MvxItemTemplate="#layout/item_myitem"/>
However, some people prefer using an empty string - although I find this a bit less readable
<Mvx.MvxLinearLayout
android:id="#+id/items"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
local:MvxBind="ItemsSource"
local:MvxItemTemplate="#layout/item_myitem"/>
This option - and lots more besides - is discussed in the data-binding article -
https://github.com/slodge/MvvmCross/wiki/Databinding
(Note: empty string binding was broken in nuget v3.0.9 but should be fixed in v3.0.10 - see Error when making bind ObservableCollection<string> for a MvxListView)

MvvmCross MvxHttpImageView error

I'm trying to bind a web image in a listview on Android, using Xamarin.Android and mvvmcross. I'm getting this error though.
MvxBind:Error: 7.13 View type not found - Mvx.MvxHttpImageView
Android.Views.InflateException: Binary XML file line #1: Error inflating class Mvx.MvxHttpImageView
This is my axml...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/com.mynamespace.android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Mvx.MvxHttpImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/iconeView"
local:MvxBind="{'HttpImageUrl':{'Path':'imageUrl'}}" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
local:MvxBind="Text name" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="10dp"
local:MvxBind="Text tagline" />
</LinearLayout>
If you are using v3, then try
MvxImageView instead of MvxHttpImageView
ImageUrl instead of HttpImageUrl
The bound views are in https://github.com/slodge/MvvmCross/tree/v3/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views
I think MvxImageView is also discussed in: http://slodge.blogspot.co.uk/2013/04/n2-lists-and-kittens-n1-days-of.html
You also need to include the MvvmCross File and DownloadCache Plugins, or else you'll get this error
"No IMvxImageHelper registered - you must provide an image helper before you can use a MvxImageView"

Resources