Не знаком с технологией xml, пытаюсь сделать "шаблон ячейки" для listView по примеру , но приложение падает при запуске на Android
С MainActivity проблем нет, это выяснил экспериментальным путем со стандартными textViewResourceId
вроде Android.Resource.Layout.SimpleListItem1
Моя конечная цель достаточно простая, в ячейке - картинка по середине
rowlayout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/icon"
android:layout_width="22px"
android:layout_height="22px"
android:layout_marginLeft="4px"
android:layout_marginRight="10px"
android:layout_marginTop="4px"
android:src="@drawable/devushka" >
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="20px">
</TextView>
</LinearLayout>
MainActivity.cs
using Android.App;
using Android.Widget;
using Android.OS;
using System;
using Android.Media;
using System.Collections.Generic;
namespace TestChart
{
[Activity(Label = "TestChart", MainLauncher = true)]
public class MainActivity : Activity
{
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
ListView listViewSlotMachine = FindViewById<ListView>(Resource.Id.listViewSlotMachine);
var adapter = new ArrayAdapter<String>(this, Resource.Layout.rowlayout, values);
// присваиваем адаптер списку
listViewSlotMachine.Adapter = adapter;
}
}
}