Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting started with the component. #3

Closed
georgepiva opened this issue Jul 31, 2013 · 6 comments
Closed

Getting started with the component. #3

georgepiva opened this issue Jul 31, 2013 · 6 comments

Comments

@georgepiva
Copy link

I am writing my first Android Application and I was trying to use this component downloaded from the Xamarin Store.

I tried to follow the Getting Started instructions in order to use the component inside my application, but I was facing these next issues:

After researching for while, I could make it work by:

  • Downloading, installing and referencing the Mono.Android.Support.v4 into my project;
  • Updating the next line:

from:
FindViewById<IPullToRefresharpView>(Resource.Id.myListView);
to
FindViewById<PullToRefresharp.Android.Widget.ListView> (Resource.Id.myListView);

  • Updating my layout:

from:
<pulltorefresharp.views.ViewWrapper and <pulltorefresharp.widget.ListView
to
<pulltorefresharp.android.views.ViewWrapper and <pulltorefresharp.android.widget.ListView

Were these fixed issues just related to my current project or are there some mistakes into the Getting Started page instructions?

Just asking because it may help others.

Btw, thank you @bduncavage by the good job you have been doing here.

@bduncavage
Copy link
Owner

It sounds like the Getting Started doc could use some more detail.

One thing to clarify could be how to use the IPullToRefresharpView from FindViewById. It sounds like you were trying to assign a variable of type ListView to IPullToRefresharpView, which won't work. The intended use is to have a variable of type IPullToRefresharpView (not ListView or GridView etc) that you use solely for PullToRefresharp communication to the view.

However, you can get a reference as the PullToRefresharp widget type, as you mention in your comment.

I will update the Getting Started docs to mention this, and fix the incorrect canonical naming of ViewWrapper and ListView in the layout example of Getting Started as well.

Thanks for bringing this up, and remember, when in doubt (from the docs), look at the sample project to verify correct usage (I will definitely try to keep the docs as accurate as possible though :)

Thanks!

@bduncavage
Copy link
Owner

Please see the latest version of README.md and let me know if that clarifies things, and would've saved you some headache :)

The README.md is just a duplicate of the Getting Started doc that ships with the Xamarin component, I will update it in the next version of the component.

@georgepiva
Copy link
Author

Cool! Thanks for updating the README.md file.
Just some more points:

var myPullToRefresharpView = FindViewById<IPullToRefresharpView>(Resource.Id.myListView);

The above line still generating the next error at compiling time:

Error CS0311: The type `PullToRefresharp.Android.Views.IPullToRefresharpView' cannot be used as type parameter `T' in the generic type or method `Android.App.Activity.FindViewById<T>(int)'. There is no implicit reference conversion from `PullToRefresharp.Android.Views.IPullToRefresharpView' to `Android.Views.View' (CS0311)

Am I missing something? But as I am using the alternative way, I am able to use the component.

Other interesting thing would be to have a wiki page explaining how developers could customize the component inside their applications.

For instance, my current application must support the Pt-BR (Portuguese - Brazil) language and so I would like to translate current component messages using my project's resources\values\strings.xml file:

...
<string name="ReleaseToRefresh_">Soltar para atualizar...</string> 
<string name="PullDownToRefresh_">Arrastar para baixo para atualizar...</string> 
<string name="Loading_">Carregando...</string> 
...

As I didn't see any string customization in the Sample provided, it would be nice to have it documented in the wiki.

Thank you for your help.

@bduncavage
Copy link
Owner

Doh, yeah, you're right, I'm sorry. You can't fetch the view directly with IPullToRefresharpView as the type, not sure what I was thinking (long week). You should fetch it as the PullToRefresharp widget type, will update readme again (i.e. the way you are doing it is the Right Way™).

You can customize the header with colors, views and localized strings, I just haven't written the docs yet :) Look in attrs.xml for available attributes you can supply to the wrapper view.

If you translate the text, feel free to submit the new strings and I'll add them as part of the component, thus slowly localizing it.

I am also planning on possibly making some header themes that ship with the library/component. But you can always override the stock header by providing your own in the layout, i.e:

<pulltorefresharp.android.views.ViewWrapper>
    <LinearLayout>
        <!-- your custom header -->
    </LinearLayout>
    <pulltorefresharp.android.widget.GridView />
</pulltorefresharp.android.views.ViewWrapper>

@georgepiva
Copy link
Author

Awesome!

Following your last instructions I could style my application without any problems:

pulltorefresh

If you would like to localize a little bit more the component, here comes a generated pull request: #4

I think it is now really easy for new developers to start using your component. You can now close this issue. Finally, thank you again for being providing us this project.

@bduncavage
Copy link
Owner

Thanks for the translations! I will take a look at that pull request as soon as I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants