Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 出现此问题:Java.Lang.RuntimeException:您的内容必须具有id属性为';android.R.id.list';_C#_Android_Listview - Fatal编程技术网

C# 出现此问题:Java.Lang.RuntimeException:您的内容必须具有id属性为';android.R.id.list';

C# 出现此问题:Java.Lang.RuntimeException:您的内容必须具有id属性为';android.R.id.list';,c#,android,listview,C#,Android,Listview,这是我的代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; namespace inicio { [Acti

这是我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace inicio
{
    [Activity(Label = "Respostas")]
    public class Respostas : ListActivity 
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Respostas);
            TextView txtnome = FindViewById<TextView>(Resource.Id.textView2);
            ListView list = FindViewById<ListView>(Resource.Id.list);
            string text = Intent.GetStringExtra("Nome") ?? "Data not available";
            txtnome.Text = text;
            var lista_respostas = Intent.Extras.GetStringArrayList("Respostas") ?? new string[0];

            list.Adapter= new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, lista_respostas);



        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用Android.App;
使用Android.Content;
使用Android.OS;
使用Android.Runtime;
使用Android.Views;
使用Android.Widget;
名称空间inicio
{
[活动(Label=“resposts”)]
公共类响应:ListActivity
{
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Respostas);
TextView txtnome=findviewbyd(Resource.Id.textView2);
ListView list=FindViewById(Resource.Id.list);
字符串文本=Intent.GetStringExtra(“Nome”)??“数据不可用”;
txtnome.Text=文本;
var lista_respostas=Intent.Extras.GetStringArrayList(“respostas”)??新字符串[0];
list.Adapter=newarrayadapter(这个,Android.Resource.Layout.SimpleListItem1,lista_respostas);
}
}
}
这是我的axml页面代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:text="Bem Vindo,"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView1" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView2" />
    <ListView
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/list" />
</LinearLayout>

每次我尝试运行我的程序时都会遇到这样的问题:Java.Lang.RuntimeException:您的内容必须有一个id属性为“android.R.id.list”的ListView

请注意,我在VisualStudio上使用C#for android


有人能告诉我怎么解决这个问题吗

使用
ListActivity
时,必须在
ListView
上使用Android SDK提供的
列表
ID


android:id=“@+id/list”
更改为
android:id=“@android:id/list”

,如果我在执行此操作时更改为:ListView list=findviewbyd(Resource.id.?);找不到我的列表视图您需要导入Android提供的资源。我不是c#人,所以我不确定名称空间是什么,但我相信你会很快找到它。我只是发布了这篇文章,因为我想找一个熟悉c#的人来回答我,无论如何谢谢你@Danail alexiev你的问题与c#无关。这一切都与Android平台有关。如果您尝试类似于Android.Resource.Id.List的东西,您应该能够找到您需要的东西。