Binding FileChooser java Library project to xamarin android

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Binding FileChooser java Library project to xamarin android

venkatesh
This post was updated on .
Hi,

I am binding filechooser library project to xamarin android .

1) filechooser.jar from eclipse build
2) Created a new Java Bindings Library project
3) Copied the generated filechooser.jar into the Jar directory and set the Build Action to "EmbeddedJar"
4) Copied the referenced android-support-v4.jar file from the android-sdk\extras folder to the Jar directory and set the Build Action to "EmbeddedReferenceJar"
5)Add the reference Mono.Android.Support.V4  to the binding project
6) Attempted to build the project and got the errors .


Error 1 :
'Com.Ipaulpro.Afilechooser.FileListFragment' does not implement interface member 'Android.Support.V4.App.LoaderManager.ILoaderCallbacks.OnLoadFinished(Android.Support.V4.Content.Loader, Java.Lang.Object)'

Java Code
===========

public class FileListFragment extends ListFragment implements
                LoaderManager.LoaderCallbacks<List<File>> {

@Override
        public void onLoadFinished(Loader<List<File>> loader, List<File> data) {
                mAdapter.setListItems(data);

                if (isResumed())
                        setListShown(true);
                else
                        setListShownNoAnimation(true);
        }

}


generated C# Code
==============

namespace Com.Ipaulpro.Afilechooser {

        // Metadata.xml XPath class reference: path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileListFragment']"

        [global::Android.Runtime.Register ("com/ipaulpro/afilechooser/FileListFragment", DoNotGenerateAcw=true)]

        public partial class FileListFragment : global::Android.Support.V4.App.ListFragment, global::Android.Support.V4.App.LoaderManager.ILoaderCallbacks {

internal static IntPtr java_class_handle;
internal static IntPtr class_ref {
get {
return JNIEnv.FindClass ("com/ipaulpro/afilechooser/FileListFragment", ref java_class_handle);
}
}


static IntPtr id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_;

// Metadata.xml XPath method reference:    path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileListFragment']/method[@nam e='onLoadFinished' and count(parameter)=2 and parameter[1]
[@type='android.support.v4.content.Loader'] and parameter[2][@type='java.util.List']]"

[Register ("onLoadFinished", "(Landroid/support/v4/content/Loader;Ljava/util/List;)V",                                  "GetOnLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_Handler")]

public virtual void OnLoadFinished (global::Android.Support.V4.Content.Loader p0,    global::System.Collections.Generic.IList<global::Java.IO.File> p1)
{
if (id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_ == IntPtr.Zero)
id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_ = JNIEnv.GetMethodID (class_ref, "onLoadFinished", "(Landroid/support/v4/content/Loader;Ljava/util/List;)V");
IntPtr native_p1 = global::Android.Runtime.JavaList<global::Java.IO.File>.ToLocalJniHandle (p1);
if (GetType () == ThresholdType)
JNIEnv.CallVoidMethod  (Handle, id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_, new JValue (p0), new JValue (Java.Interop.JavaObjectExtensions.ToInteroperableCollection (p1)));
else
JNIEnv.CallNonvirtualVoidMethod  (Handle, ThresholdClass, id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_, new JValue (p0), new JValue (Java.Interop.JavaObjectExtensions.ToInteroperableCollection (p1)));
JNIEnv.DeleteLocalRef (native_p1);
}


Error 2 :

'Com.Ipaulpro.Afilechooser.FileLoader.LoadInBackground()': return type must be 'Java.Lang.Object' to match overridden member 'Android.Support.V4.Content.AsyncTaskLoader.LoadInBackground()'

Java Code :
========
public class FileLoader extends AsyncTaskLoader<List<File>> {

@Override
        public List<File> loadInBackground() {
                return FileUtils.getFileList(mPath);
        }

}

Generated C# Code :
=================
static IntPtr id_loadInBackground;
// Metadata.xml XPath method reference: path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileLoader']/method[@name='loadInBackground' and count(parameter)=0]"

[Register ("loadInBackground", "()Ljava/util/List;", "GetLoadInBackgroundHandler")]
public override global::System.Collections.Generic.IList<global::Java.IO.File> LoadInBackground ()
{
if (id_loadInBackground == IntPtr.Zero)
id_loadInBackground = JNIEnv.GetMethodID (class_ref, "loadInBackground", "()Ljava/util/List;");
if (GetType () == ThresholdType)
return global::Android.Runtime.JavaList<global::Java.IO.File>.FromJniHandle (JNIEnv.CallObjectMethod  (Handle, id_loadInBackground), JniHandleOwnership.TransferLocalRef);
else
return global::Android.Runtime.JavaList<global::Java.IO.File>.FromJniHandle (JNIEnv.CallNonvirtualObjectMethod  (Handle, ThresholdClass, id_loadInBackground), JniHandleOwnership.TransferLocalRef);
                }

i have embeded the api.xml for reference.api.xmlapi.xml

Kindly suggest me how to solve the above issues as i am struggling the past two days .


Thanks

Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

Jonathan Pryor-2
On Sep 25, 2013, at 3:07 AM, venkatesh <[hidden email]> wrote:
> I am binding filechooser library project to xamarin android .
>
> 1) filechooser.jar from eclipse build
> 2) Created a new Java Bindings Library project
> 3) Copied the generated filechooser.jar into the Jar directory and set the Build Action to "EmbeddedJar"
> 4) Copied the referenced android-support-v4.jar file from the android-sdk\extras folder to the Jar directory and set the Build Action to "EmbeddedReferenceJar"
> 5)Add the reference Mono.Android.Support.V4  to the binding project

There are lots of android-support-v4.jar's, and the android-support-v4.jar that filechooser.jar probably differs from the one in the Mono.Android.Support.V4.dll assembly.

You'll also be including _both_ android-support-v4.jar's into your final app, which will likely confuse things. I would suggest removing android-support-v4.jar from your binding project and just sticking with Mono.Android.Support.V4.dll.

> 6) Attempted to build the project and got the errors .
>
>
> *Error 1 :* 'Com.Ipaulpro.Afilechooser.FileListFragment' does not implement interface member 'Android.Support.V4.App.LoaderManager.ILoaderCallbacks.OnLoadFinished(Android.Support.V4.Content.Loader, Java.Lang.Object)'

The "generated C# Code" you provide doesn't have any OnLoadFinished() member. :-(

Is it there but not added in the email? Are there any warnings? Perhaps the member is being skipped? Could you please provide diagnostic build output?

        http://docs.xamarin.com/guides/android/deployment%2c_testing%2c_and_metrics/diagnostics

I do see FileListFragment.onLoadFinished() declared within api.xml, so it _should_ be bound, though it's possible that the nested generics on the parameter types are confusing things. If that's the case, you can fix that by adding the following to Transforms\Metadata.xml:

        <attr
                path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileChooserFragment']/method[@name='onLoadFinished']/parameter[@name='p0']"
                name="type"
        >android.support.v4.content.Loader</attr>
        <attr
                path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileChooserFragment']/method[@name='onLoadFinished']/parameter[@name='p1']"
                name="type"
        >java.util.List </attr>

_However_, even once bound the parameter types won't match the expected LoaderManager.ILoaderCallbacks.OnLoadFinished(Android.Support.V4.Content.Loader, Java.Lang.Object) argument list. You will thus need to provide a partial class declaration to implement this member:

        // Add a new class to your solution:
        namespace Com.Ipaulpro.Afilechooser {
                partial class FileListFragment {
                        public void OnLoadFinished(Android.Support.V4.Content.Loader loader, Java.Lang.Object value)
                        {
                                OnLoadFinished(loader, (Java.Util.List) value);
                        }
                }
        }

> *Error 2 :*
>
> 'Com.Ipaulpro.Afilechooser.FileLoader.LoadInBackground()': return type must be 'Java.Lang.Object' to match overridden member 'Android.Support.V4.Content.AsyncTaskLoader.LoadInBackground()'

Our binding infrastructure doesn't cleanly handle Java covariant return types, and requires some help:

        http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)#4.9.1.possible-causes

You'll need to edit Transforms\Metadata.xml and add something similar to the following fragment:

        <attr
                path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileLoader']/method[@name='loadInBackground']"
                name="managedReturn"
        >Java.Lang.Object</attr>

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

venkatesh
This post was updated on .
Hi Jon,

Thanks for your prompt reply.


I have solved

Error 2 :*

 
'Com.Ipaulpro.Afilechooser.FileLoader.LoadInBackground()': return type must be 'Java.Lang.Object' to match overridden member 'Android.Support.V4.Content.AsyncTaskLoader.LoadInBackground()'


by adding these lines in Metadata.xml as per your suggestions

<attr path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileLoader']/method[@name='loadInBackground']" name="managedReturn" >Java.Lang.Object</attr>

It works great.


I am not able to solve the Error no 1 :

Error No 1:


*Error 1 :* 'Com.Ipaulpro.Afilechooser.FileListFragment' does not implement interface member 'Android.Support.V4.App.LoaderManager.ILoaderCallbacks.OnLoadFinished(Android.Support.V4.Content.Loader, Java.Lang.Object)'

I have done the steps given by you .

1. Transform/Metadata.xml

 <attr              path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileListFragment']/method[@name='onLoadFinished']/parameter[@name='p0']" name="type" android.support.v4.content.Loader</attr> 
<attr                 path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileListFragment']/method[@name='onLoadFinished']/parameter[@name='p1']"  name="type" >java.util.List </attr> 

2.Add a new  partial class to my binding solution as per your suggestions

// Add a new class to your solution:
   namespace Com.Ipaulpro.Afilechooser {
   partial class FileListFragment {
   public void OnLoadFinished(Android.Support.V4.Content.Loader loader, Java.Lang.Object value)
   {
    OnLoadFinished(loader, (Java.Util.List) value);
    }
     }
     }


3. after building , i got bunch of errors.

Error 1        The best overloaded method match for Android.Runtime.JavaList<Java.IO.File>.ToLocalJniHandle(System.Collections.Generic.IList<Java.IO.File>)' has some invalid arguments C:\Users\venkatesh.r\documents\visual studio 2010\Projects\FileChooser\FileChooser\obj\Debug\generated\src\Com.Ipaulpro.Afilechooser.FileLoader.cs 94 11 FileChooser

Error 2        Argument 1: cannot convert from 'Java.Lang.Object' to 'System.Collections.Generic.IList<Java.IO.File>' C:\Users\venkatesh.r\documents\visual studio 2010\Projects\FileChooser\FileChooser\obj\Debug\generated\src\Com.Ipaulpro.Afilechooser.FileLoader.cs 94 84 FileChooser

Error 3        Cannot implicitly convert type 'System.Collections.Generic.IList<Java.IO.File>' to 'Java.Lang.Object'. An explicit conversion exists (are you missing a cast?) C:\Users\venkatesh.r\documents\visual studio 2010\Projects\FileChooser\FileChooser\obj\Debug\generated\src\Com.Ipaulpro.Afilechooser.FileLoader.cs 107 12 FileChooser

Error 4        Cannot implicitly convert type 'System.Collections.Generic.IList<Java.IO.File>' to 'Java.Lang.Object'. An explicit conversion exists (are you missing a cast?) C:\Users\venkatesh.r\documents\visual studio 2010\Projects\FileChooser\FileChooser\obj\Debug\generated\src\Com.Ipaulpro.Afilechooser.FileLoader.cs 109 12 FileChooser

Error 5        The type or namespace name 'List' does not exist in the namespace 'Java.Util' (are you missing an assembly reference?) C:\Users\venkatesh.r\documents\visual studio 2010\Projects\FileChooser\FileChooser\FileListFragment.cs 19 46 FileChooser



Generated C# code for OnLoadFinished() member

static IntPtr id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_;
                // Metadata.xml XPath method reference: path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileListFragment']/method[@name='onLoadFinished' and count(parameter)=2 and parameter[1][@type='android.support.v4.content.Loader'] and parameter[2][@type='java.util.List']]"
[Register ("onLoadFinished", "(Landroid/support/v4/content/Loader;Ljava/util/List;)V", "GetOnLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_Handler")]
public virtual void OnLoadFinished (global::Android.Support.V4.Content.Loader p0, global::System.Collections.IList p1)
{
if (id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_ == IntPtr.Zero)
id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_ = JNIEnv.GetMethodID (class_ref, "onLoadFinished", "(Landroid/support/v4/content/Loader;Ljava/util/List;)V");
IntPtr native_p1 = global::Android.Runtime.JavaList.ToLocalJniHandle (p1);
if (GetType () == ThresholdType)
JNIEnv.CallVoidMethod  (Handle, id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_, new JValue (p0), new JValue (Java.Interop.JavaObjectExtensions.ToInteroperableCollection (p1)));
else
JNIEnv.CallNonvirtualVoidMethod  (Handle, ThresholdClass, id_onLoadFinished_Landroid_support_v4_content_Loader_Ljava_util_List_, new JValue (p0), new JValue (Java.Interop.JavaObjectExtensions.ToInteroperableCollection (p1)));
JNIEnv.DeleteLocalRef (native_p1);
}



I have attached diagnostic output for this build with api.xml

Diagnostic output build from Visual Studio   : diagnostic_log.txt

api.xml  :     api.xml


Kindly suggest me what i went wrong?


Thanks

Venkatesh.R











Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

Jonathan Pryor-2
On Sep 26, 2013, at 4:36 AM, venkatesh <[hidden email]> wrote:

> I have done the steps given by you .
>
> 2.Add a new  partial class to my binding solution as per your suggestions
>
> // Add a new class to your solution:
>   namespace Com.Ipaulpro.Afilechooser {
>   partial class FileListFragment {
>   public void OnLoadFinished(Android.Support.V4.Content.Loader loader,
> Java.Lang.Object value)
>   {
>    OnLoadFinished(loader, (Java.Util.List) value);

My bad; it's Java.Util.IList, not Java.Util.List, but even that is mistaken as the generated method is OnLoadFinished(Loader, System.Collections.IList), so you'll actually need:

        OnLoadFinished(loader, (System.Collections.IList) value);

> 3. after building , i got bunch of errors.

Unfortunately your diagnostic build output didn't include the generation output, so I can't see what warnings were emitted by the generator. If you clean and rebuild your project, they should be present.

> *Error 1* The best overloaded method match for
> Android.Runtime.JavaList<Java.IO.File>.ToLocalJniHandle(System.Collections.Generic.IList<Java.IO.File>)'
> has some invalid arguments C:\Users\venkatesh.r\documents\visual studio
> 2010\Projects\FileChooser\FileChooser\obj\Debug\generated\src\Com.Ipaulpro.Afilechooser.FileLoader.cs
> 94 11 FileChooser

This doesn't make sense to me. :-(

Can you provide the generated\src\Com.Ipaulpro.Afilechooser.FileLoader.cs contents as well as the "complete" build output?

Thanks,
 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

venkatesh
This post was updated on .
Hi John,

Thanks for your wonderful support.

I have changed the casting type to (System.Collections.IList) in the new partial class as per your suggestions.

namespace Com.Ipaulpro.Afilechooser
{
    partial class FileListFragment
    {
        public void OnLoadFinished(Android.Support.V4.Content.Loader loader, Java.Lang.Object value)
        {
            OnLoadFinished(loader, (System.Collections.IList) value);
        }
    }
}

Now , i  build the solutin  with  errors.

Here with i have attached generated  FileLoader.cs , "Complete" build output and original filechooser java library project.


1. Complete Build Log    :buildlog

2. Generated "src\Com.Ipaulpro.Afilechooser.FileLoader.cs"   :  
Com.Ipaulpro.Afilechooser.FileLoader.cs

3. api.xml file             :       api.xml

4. Metadata.xml        :    metadata.txt

4.  Complete FileChooser Java Library Project     :   aFileChooser.rar             


Please provide your valuable thoughts and suggestions to proceed on solve this issue.


Thanks

Venkatesh.R
Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

venkatesh
Hi Jon,

Could you please guide me to solve this issue.

Thanks

Venkatesh.R
Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

Jonathan Pryor-2
In reply to this post by venkatesh
On Sep 27, 2013, at 12:36 AM, venkatesh <[hidden email]> wrote:
> Thanks for your wonderful support.

Thank you for providing aFileChooser.rar; that makes things significantly easier...

Please see http://www.jprl.com/tmp/Scratch.FileChooser.zip

> *Error 1* The best overloaded method match for
> Android.Runtime.JavaList<Java.IO.File>.ToLocalJniHandle(System.Collections.Generic.IList<Java.IO.File>)'
> has some invalid arguments C:\Users\venkatesh.r\documents\visual studio
> 2010\Projects\FileChooser\FileChooser\obj\Debug\generated\src\Com.Ipaulpro.Afilechooser.FileLoader.cs
> 94 11 FileChooser

You were getting this error because I had told you to use Transforms\Metadata.xml to change the FileLoader.LoadInBackground() return type to Java.Lang.Object, and thus the generated code was effectively:

        var r = JavaList<File>.ToLocalJniHandle((Java.Lang.Object) LoadInBackground());

Since there is no JavaList<T>.ToLocalJniHandle(Java.Lang.Object) method, this failed to compile.

The fix for this is to _not_ use managedReturn, as I had previously suggested, but to instead _rename_ the method:

          <attr
              path="/api/package[@name='com.ipaulpro.afilechooser']/class[@name='FileLoader']/method[@name='loadInBackground' and count(parameter)=0]"
              name="managedName"
          >_LoadInBackground</attr>

This means that FileLoader.LoadInBackground() no longer exists, and is no longer overridden, allowing a partial class declaration to provide it:

        partial class FileLoader
        {
                public override Java.Lang.Object LoadInBackground ()
                {
                        return (Java.Lang.Object) _LoadInBackground ();
                }
        }

FileListFragment.OnLoadFinished() is also be implemented with a partial class, just with the appropriate casts.

As a "bonus", the aFileChooser.Binding.csproj project uses a pre-build step to build the aFileChooser.Binding\java\aFileChooser Java project and create an Jars\aFileChooser.zip, which is used as a $(LibraryProjectZip). This allows all .class and resources to be included in the aFileChooser.Binding.dll assembly, allowing the included sample app to Just Work.

Note: above magic requires that `zip` be in $PATH; only tested on OS X.

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

venkatesh
Hi Jon,

Thanks for your wonderful support. I will check  and update you.

Thanks

Venkatesh.R
Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

venkatesh
In reply to this post by Jonathan Pryor-2
Hi Jon,

Thanks for your wonderful support. I will check  and update you.

Thanks

Venkatesh.R
Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

venkatesh
Hi Jon,

Thanks for your wonderful support. filechooser binding project works very well in android application.


Thanks,

Venkatesh.R
Reply | Threaded
Open this post in threaded view
|

NavigationDrawer on Android 2.3

Vladimir Dimitrov
Hey guys,

did someone got a working NavigationDrawer with and older version of
Android? My problem is that I have to communicate with ActionBar which
is available through the Mono.Anroid.Support.v7 which does not exist afaik.

I tried with the SherlockActionBar but it uses it's own version of some
interfaces like IMenu and this causes a problem while trying to connect
with the NavigationDrawer.

Thanks,
  Vladimir
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: NavigationDrawer on Android 2.3

Jared Kells
Hey Vladimir,

I've got the Navigation Drawer working on 2.3 with both ActionBarSherlock and the support library ActionBar.

If you are using ActionBarSherlock you just need need to subclass ActionBarDrawerToggle and provide an implementation of OnOptionsItemSelected that takes the ActionBarSherlock version of IMenuItem.
Fortunately it's pretty straightforward:

    public class MainActivityDrawerToggle : ActionBarDrawerToggle
    {
        private const decimal IdHome = 0x0102002c;
        private readonly DrawerLayout _drawerLayout;

        public MainActivityDrawerToggle(Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes)
            : base(activity, drawerLayout, drawerImageRes, openDrawerContentDescRes, closeDrawerContentDescRes)
        {
            _drawerLayout = drawerLayout;
        }

        public bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item != null && (item.ItemId == IdHome || item.ItemId == Resource.Id.abs__home))
            {
                if (_drawerLayout.IsDrawerVisible(GravityCompat.Start))
                    _drawerLayout.CloseDrawer(GravityCompat.Start);
                else
                    _drawerLayout.OpenDrawer(GravityCompat.Start);
                return true;
            }
            return false;
        }
    }

If you want to use the V7-AppCompat library I have some bindings here: https://github.com/jkells/xamarin-android-support-binding there are instructions in the readme but you need to use the revision 18 version of the v4 support library from the component store and you need to build the v7-appcompat library in eclipse first.

Cheers,
Jared




On Sat, Oct 5, 2013 at 5:02 AM, Vladimir Dimitrov <[hidden email]> wrote:
Hey guys,

did someone got a working NavigationDrawer with and older version of Android? My problem is that I have to communicate with ActionBar which is available through the Mono.Anroid.Support.v7 which does not exist afaik.

I tried with the SherlockActionBar but it uses it's own version of some interfaces like IMenu and this causes a problem while trying to connect with the NavigationDrawer.

Thanks,
 Vladimir
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: NavigationDrawer on Android 2.3

Vladimir Dimitrov
Thanks Jared,

The Sherlock solution worked well. The only thing I have left to fix about the navigation is the 3 stripe icon that is supposed to show in the action bar. Instead of it I get the Up icon.

I use:
            SupportActionBar.SetDisplayHomeAsUpEnabled (true);
            SupportActionBar.SetHomeButtonEnabled (true);

and the image sent to the custom toggle class. This code works fine on a newer device (Android 4.2) probably it is some kind of a limitation in the Sherlock implementation which takes place on older androids...

- Vladimir

On 5.10.2013 г. 01:39 ч., Jared Kells wrote:
Hey Vladimir,

I've got the Navigation Drawer working on 2.3 with both ActionBarSherlock and the support library ActionBar.

If you are using ActionBarSherlock you just need need to subclass ActionBarDrawerToggle and provide an implementation of OnOptionsItemSelected that takes the ActionBarSherlock version of IMenuItem.
Fortunately it's pretty straightforward:

    public class MainActivityDrawerToggle : ActionBarDrawerToggle
    {
        private const decimal IdHome = 0x0102002c;
        private readonly DrawerLayout _drawerLayout;

        public MainActivityDrawerToggle(Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes)
            : base(activity, drawerLayout, drawerImageRes, openDrawerContentDescRes, closeDrawerContentDescRes)
        {
            _drawerLayout = drawerLayout;
        }

        public bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item != null && (item.ItemId == IdHome || item.ItemId == Resource.Id.abs__home))
            {
                if (_drawerLayout.IsDrawerVisible(GravityCompat.Start))
                    _drawerLayout.CloseDrawer(GravityCompat.Start);
                else
                    _drawerLayout.OpenDrawer(GravityCompat.Start);
                return true;
            }
            return false;
        }
    }

If you want to use the V7-AppCompat library I have some bindings here: https://github.com/jkells/xamarin-android-support-binding there are instructions in the readme but you need to use the revision 18 version of the v4 support library from the component store and you need to build the v7-appcompat library in eclipse first.

Cheers,
Jared




On Sat, Oct 5, 2013 at 5:02 AM, Vladimir Dimitrov <[hidden email]> wrote:
Hey guys,

did someone got a working NavigationDrawer with and older version of Android? My problem is that I have to communicate with ActionBar which is available through the Mono.Anroid.Support.v7 which does not exist afaik.

I tried with the SherlockActionBar but it uses it's own version of some interfaces like IMenu and this causes a problem while trying to connect with the NavigationDrawer.

Thanks,
 Vladimir
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid



_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: NavigationDrawer on Android 2.3

Vladimir Dimitrov
In reply to this post by Jared Kells
By the way, have you uploaded somewhere a built NuGet with the v7 support library? That would probably be the better solution. What is your experience?

On 5.10.2013 г. 01:39 ч., Jared Kells wrote:
Hey Vladimir,

I've got the Navigation Drawer working on 2.3 with both ActionBarSherlock and the support library ActionBar.

If you are using ActionBarSherlock you just need need to subclass ActionBarDrawerToggle and provide an implementation of OnOptionsItemSelected that takes the ActionBarSherlock version of IMenuItem.
Fortunately it's pretty straightforward:

    public class MainActivityDrawerToggle : ActionBarDrawerToggle
    {
        private const decimal IdHome = 0x0102002c;
        private readonly DrawerLayout _drawerLayout;

        public MainActivityDrawerToggle(Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes)
            : base(activity, drawerLayout, drawerImageRes, openDrawerContentDescRes, closeDrawerContentDescRes)
        {
            _drawerLayout = drawerLayout;
        }

        public bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item != null && (item.ItemId == IdHome || item.ItemId == Resource.Id.abs__home))
            {
                if (_drawerLayout.IsDrawerVisible(GravityCompat.Start))
                    _drawerLayout.CloseDrawer(GravityCompat.Start);
                else
                    _drawerLayout.OpenDrawer(GravityCompat.Start);
                return true;
            }
            return false;
        }
    }

If you want to use the V7-AppCompat library I have some bindings here: https://github.com/jkells/xamarin-android-support-binding there are instructions in the readme but you need to use the revision 18 version of the v4 support library from the component store and you need to build the v7-appcompat library in eclipse first.

Cheers,
Jared




On Sat, Oct 5, 2013 at 5:02 AM, Vladimir Dimitrov <[hidden email]> wrote:
Hey guys,

did someone got a working NavigationDrawer with and older version of Android? My problem is that I have to communicate with ActionBar which is available through the Mono.Anroid.Support.v7 which does not exist afaik.

I tried with the SherlockActionBar but it uses it's own version of some interfaces like IMenu and this causes a problem while trying to connect with the NavigationDrawer.

Thanks,
 Vladimir
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid



_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: NavigationDrawer on Android 2.3

Jared Kells
I put the NuGet packages for up here: https://www.myget.org/F/jkells/

Cheers,
Jared



On Sat, Oct 5, 2013 at 10:50 AM, Vladimir Dimitrov <[hidden email]> wrote:
By the way, have you uploaded somewhere a built NuGet with the v7 support library? That would probably be the better solution. What is your experience?


On 5.10.2013 г. 01:39 ч., Jared Kells wrote:
Hey Vladimir,

I've got the Navigation Drawer working on 2.3 with both ActionBarSherlock and the support library ActionBar.

If you are using ActionBarSherlock you just need need to subclass ActionBarDrawerToggle and provide an implementation of OnOptionsItemSelected that takes the ActionBarSherlock version of IMenuItem.
Fortunately it's pretty straightforward:

    public class MainActivityDrawerToggle : ActionBarDrawerToggle
    {
        private const decimal IdHome = 0x0102002c;
        private readonly DrawerLayout _drawerLayout;

        public MainActivityDrawerToggle(Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes)
            : base(activity, drawerLayout, drawerImageRes, openDrawerContentDescRes, closeDrawerContentDescRes)
        {
            _drawerLayout = drawerLayout;
        }

        public bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item != null && (item.ItemId == IdHome || item.ItemId == Resource.Id.abs__home))
            {
                if (_drawerLayout.IsDrawerVisible(GravityCompat.Start))
                    _drawerLayout.CloseDrawer(GravityCompat.Start);
                else
                    _drawerLayout.OpenDrawer(GravityCompat.Start);
                return true;
            }
            return false;
        }
    }

If you want to use the V7-AppCompat library I have some bindings here: https://github.com/jkells/xamarin-android-support-binding there are instructions in the readme but you need to use the revision 18 version of the v4 support library from the component store and you need to build the v7-appcompat library in eclipse first.

Cheers,
Jared




On Sat, Oct 5, 2013 at 5:02 AM, Vladimir Dimitrov <[hidden email]> wrote:
Hey guys,

did someone got a working NavigationDrawer with and older version of Android? My problem is that I have to communicate with ActionBar which is available through the Mono.Anroid.Support.v7 which does not exist afaik.

I tried with the SherlockActionBar but it uses it's own version of some interfaces like IMenu and this causes a problem while trying to connect with the NavigationDrawer.

Thanks,
 Vladimir
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid



_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid



_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Binding FileChooser java Library project to xamarin android

sagar
In reply to this post by Jonathan Pryor-2
  hi  
Jonathan Pryor-2

I downloaded your code from http://www.jprl.com/tmp/Scratch.FileChooser.zip

but aFileChooser.zip is missing from the project

while  i m trying to run that project it gives me error

Error 1 The command "ant debug" exited with code 9009

please provide me library project link

which is running

thanks in advance man