- Xamarin Blueprints
- Michael Williams
- 225字
- 2021-07-08 11:48:19
Creating an XML interface and ListView
Our starting point is the main.xml
sheet; this is where we will be creating the ListView
:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ListView android:id="@+id/listView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginBottom="10dp" android:layout_marginTop="5dp" android:background="@android:color/transparent" android:cacheColorHint="@android:color/transparent" android:divider="#CCCCCC" android:dividerHeight="1dp" android:paddingLeft="2dp" /> </LinearLayout>
Tip
The main.xml
file should already be in the resource | layout directory, so simply copy and paste the previous code into this file.
Excellent! We now have our starting activity and interface, so now we have to create a ListAdapter
for our ListView
. An adapter works very much like a UITableSource
, where we must override functions to determine cell data, row design, and the number of items in the list.
Note
Xamarin Studio also has an Android GUI designer.
Right-click on the Android project and add a new empty class file for our adapter class. Our class must inherit the BaseAdapter
class, and we are going to override the following functions:
public override long GetItemId(int position); public override View GetView(int position, View convertView, ViewGroup parent);
Before we go any further, we need to create a model for the objects used to contain the data to be presented in each row. In our iOS project, we created a GalleryItem
to hold the byte array of image data used to create each UIImage
. We have two approaches here: we could create another object to do the same as the GalleryItem
, or even better, why don't we reuse this object using a shared project?
- SPSS數據挖掘與案例分析應用實踐
- 玩轉Scratch少兒趣味編程
- Kubernetes實戰
- Instant Zepto.js
- 動手玩轉Scratch3.0編程:人工智能科創教育指南
- PHP網絡編程學習筆記
- Kinect for Windows SDK Programming Guide
- R Deep Learning Cookbook
- Oracle Exadata專家手冊
- Arduino家居安全系統構建實戰
- Learning Concurrent Programming in Scala
- Geospatial Development By Example with Python
- Building Dynamics CRM 2015 Dashboards with Power BI
- Swift語言實戰晉級
- Xamarin Blueprints