In this article, you will learn how to create SwipeRefreshLayout with ListView Items in Android.
Let’s start,
Step 1: Open Visual Studio->New Project->Templates->Visual C#->Android->Blank App
Select Blank App. Give the Project Name and Project Location.Step 2Go to Solution Explorer-> Project Name-> Components, right click to Get More Components and the new dialog box opens. This dialog box is required to search the Support V4, add the Android Support Library V4 Packages. Step 3: To open Solution Explorer, go to -> Project Name->Resources->layout ->Main.axml, click to open Design View and the code, given below:
Step 4: After Design view creation, open Solution Explorer-> Project Name->MainActivity.cs, add the namespaces, given below:
Step 5: To create the new variables for RefreshLayout and ListView, one can use the code, given below:
Step 6: Go to Oncreate() to declare the list view id and Listview<string>Variable.
Step 7: Next step is to create one List String Item and then add the list view adapter.C# Code
Step 8After Listview declaration, assign Refresh Layout variables and colors. Here, create one more method for Refresh event. This event is declared after Oncreate(). C# Code
Step 9Declare RefreshLayout_refresh method. This method is working in the background process of the layout. Once the work completes, it will terminate the work. C# Code
Step 10: Press F5 or build and run the Application.Finally, we successfully created Xamarin Android SwipeRefreshLayout with ListView items.
Xamarin.Forms For Beginners