0

I've been fixing a library in Xamarin.Android:

https://stackoverflow.com/a/56778629/2889347

However, I found that an important method is missing in my code:

/**
 * Sets a custom adapter for suggestions list view.
 *
 * @param suggestionAdapter customized adapter
 */
public void setCustomSuggestionAdapter(SuggestionsAdapter suggestionAdapter) {
    this.adapter = suggestionAdapter;
    RecyclerView recyclerView = findViewById(R.id.mt_recycler);
    recyclerView.setAdapter(adapter);
}

I tried to implement a partial class:

using System;
using System.Collections.Generic;
using Android.Runtime;
using Java.Interop;

namespace Com.Mancj.Materialsearchbar
{

    public partial class MaterialSearchBar
    {
    }
}

But I get a message like this one:

Partial class with single part.

The generated class is this one: https://www.dropbox.com/s/cb9oqtp6efys843/Com.Mancj.Materialsearchbar.MaterialSearchBar.cs?dl=0

I experienced in the past still a very specific issue that I couldn't use the FindViewByID since it was not able to find anything and I also tried a code like this one in my Metadata.xml:

<add-node path="/api/package[@name='com.mancj.materialsearchbar.adapter']/class[@name='MaterialSearchBar']/method[@name='setCustomSuggestionAdapter'] and count(parameter)=1 and parameter[1][@type='Com.Mancj.Materialsearchbar.Adapter.SuggestionsAdapter']" />

But the VS crashes:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.targets(5,5): Error MSB6006: "generator.exe" exited with code 1. (MSB6006) (Xamarin-SearchBar-V2)

If you want to test my current version of the code:

https://github.com/FANMixco/Xamarin-SearchBar

Thanks for any idea.

Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
  • have you tried using Metadata.xml to add a `partial` keyword to the `MaterialSearchBar` class? – Jason Jun 27 '19 at 22:54
  • Hi @Jason, how can I add it? Also, my second question, how can I access the ID (R.id.mt_recycler)? Because that was my greatest trouble the previous time since this is part of the resources of the project. Thanks. – Federico Navarrete Jun 28 '19 at 03:38
  • Hi @Jason, I found this old topic, https://web.archive.org/web/20181020124735/https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/troubleshooting-bindings/, but they only advice it as in your case, but there was not description of how to add the word partial. – Federico Navarrete Jun 28 '19 at 03:50
  • not an expert at Android bindings, but I think you would remove the original node for the class and then re-add it including the partial keyword – Jason Jun 28 '19 at 05:43

0 Answers0