Creating a custom alert view in Android using C#

As mentioned in my earlier post, we can use the default AlertDialog class to display the alerts of screen by setting different properties and methods of it. But still there sounds like, we may need dialogs on screen which would be needed to be customized. They can be accept user inputs, can display an arranged info of an user etc.

How to do it ?


We will follow few simple steps

  • Create a custom view
  • Render the custom view in AlertDialog

Create a custom view


Let’s add a new layout to the project under Resources > layout.
AddedNewLayout

Read More

Quick Tips : Displaying an Alert in Android using MonoDroid

Displaying an informational alert on screen


Let’s just display a quick informative popup, which will only display an alert on screen with a title and a message in it. It actually gets closed when the back button get touched.

AndroidAlertWithoutButton

Let’s display the OK and Cancel button

We will add OK and Canel button. On click of the buttons, it will display a quick Toast message on screen in order
to differentiate which button is clicked.

Read More

More data in a row : Android Listview using Xamarin

What do you want ?

I just wanted to add a date along with the each place of earthquake that is in the list in my previous blog.

We can use any of the way, like ListActivity or adding a ListView control to the Layout. Here I am going to do it with the ListView control.

Steps to do it

Pretty simple steps.

  • Add a Listview to the layout
  • Create a class or dictionary to contain the custom list of data
  • Customize the Adapter to contain the custom data
  • Use the custom Adapter instead of the default Adapter

Read More

A simple way to show listview in Android using Xamarin

Ways to do it

There are basically 2 ways to do it in Android.

  • Using the Listview control
  • Using the ListActivity

By using ListActivity

In this way we don’t need to define any Listview in our AXML page. Just few lines of code will do it.

Read More

Child control Event handling in Listview using Xamarin.Forms

We can add child controls to Listview in Xamarin.Forms. In order to see the child control in action we will take an example. Let’s display a list of data in the Listview and perform delete option on the list data per row basis.

Since we need to add multiple columns in the list view, we need to use the DataTemplate to define the custom view. Let’s use a model class to assign the data to the custom view.

We will use XAML to design a Listview

InsideXAMLView
In the above XAML, we have used the StackLayout as the parent container for the child views. It contains a Label and a Listview. UI Control is ready.

Time to add event to the child control
We will replace the Button control in the above XAML with the following line

Read More

Display requirement specific keyboard using Xamarin.Forms

Xamarin uses the Keyboard class to show different virtual keyboards depending upon the user request. It contains several static properties to create different kind of virtual keyboards. Xamarin displays the Default Keyboard, if nothing is specified.

Keyboard for Chatting

ChatKeyboard

It opens up the default virtual keyboard in the device, which would be convenient for chatting, having few extra keys.

Read More

Using a Scrollview in XamarinForms

What is it ???

The short answer is ScrollView is a Layout. But it can only contain a single Visual Element in its Content property.

Why So ???

Because, the Layouts such as Stack, relative etc. are derived from Layout<T> generic class. This Layout<T> generic class is derived from the Layout class, which is a non-generic class.

ScrollView is inherited from the Non-generic Layout class. That is the same reason, why it does not support a generic way to add children. It only exhibits the Content property to accept a single view or a Layout.

ScrollView

Usage by example

Usage Example #1 : Let’s display a paragraph of scrolling text

Read More

Customizing Listview display in Xamarin

As the usual behavior of ListView to display the items in a list and it contains a single column. The ItemSource property of Listview accepts the list of data to be displayed and render the same on screen.

The code for a simple list to display the Students of a class would like as in the following pic.

ListViewInXamarinForms

Now let’s customize this ListView in a way to display the Student Name along with the Class and School they belongs to.

ListViewItem

As in the image above, the data contains a single record. So to accommodate the data in a single record, Let’s create a Student model class.

In order to customize the ListView display, we need to override the ViewCell class.

Read More

What’s new in Xamarin.Forms 1.3 : Inherited App Class

With the new release of Xamarin.Forms 1.3 version, the App Class has its new Avatar. The Older version of App Class was just a class with static methods. Unlike the older version, the new version is an inherited class from the Xamarin.Forms.Application class. Summary of improvements Addition of new life cycle events : We can

Read More

Xamarin.Forms.DependencyService platform tweaks

What is DependencyService in Xamarin ?

DependencyService is a static class under Xamarin.Forms namespace. Shared or Portable projects can access the platform based tweaks that are done in any specific platform projects by using DependencyService.

How it works?

The key point is by defining an Interface.

  • Declare an Interface in the Shared / Portable project.
  • Implement the interface in platform specific projects.
  • Register the class under DependencyService Assembly with Dependency attribute.
  • Call the DependencyService.get method with the Interface. It will identify the platform and executes the implementation

Xamarin.Form.DependencyService

 

Read More

1 2
%d bloggers like this: