点击ListView-Android c#Xamarin,从Strings.xml中删除项目
我有一个ListView,它从Strings.xml字符串数组中检索和显示数据。 我想知道如果在ListView中点击字符串,如何从Strings.xml数组中删除该字符串 主要活动:点击ListView-Android c#Xamarin,从Strings.xml中删除项目,c#,android,arrays,listview,xamarin,C#,Android,Arrays,Listview,Xamarin,我有一个ListView,它从Strings.xml字符串数组中检索和显示数据。 我想知道如果在ListView中点击字符串,如何从Strings.xml数组中删除该字符串 主要活动: public class MainActivity : Activity { ListView notesList; String[] notesArray; protected override void OnCreate(Bundle bundle) { b
public class MainActivity : Activity
{
ListView notesList;
String[] notesArray;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
ActionBar.Hide();
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
notesArray = Resources.GetStringArray(Resource.Array.testStrings);
notesList = FindViewById<ListView>(Resource.Id.lvNotes);
//Load ListView Data
ArrayAdapter adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleExpandableListItem1, notesArray);
notesList.Adapter = adapter;
}
}
公共类main活动:活动
{
列表视图注释列表;
字符串[]notesArray;
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
//从“主”布局资源设置视图
SetContentView(Resource.Layout.Main);
ActionBar.Hide();
//从“主”布局资源设置视图
SetContentView(Resource.Layout.Main);
notesArray=Resources.GetStringArray(Resource.Array.testStrings);
notesList=FindViewById(Resource.Id.lvNotes);
//加载ListView数据
ArrayAdapter=新的ArrayAdapter(这个,Android.Resource.Layout.SimpleExpandableListItem1,notesArray);
notesList.Adapter=适配器;
}
}
}
和Strings.xml:
您不能在运行时修改资源。那么,我应该如何使数据可编辑并修改文件,然后保存?您必须使用其他方式来存储数据;e、 例如,一个文件、一个数据库等,这并不是说您最初无法从资源加载阵列;您只需以另一种方式保存修改后的版本,或者我可以从MainActivity中的字符串中删除它并将其保存到Strings.xml文件中吗?