选择项目时拆分微调器数据

时间:2016-12-22 08:33:48

标签: c# android xamarin spinner

我正在使用spinner.Add(" heading" +23)将项目添加到微调器,并在spinner列表中显示heading23。如何将数据返回两个变量(一个用于标题,一个用于int值)。

2 个答案:

答案 0 :(得分:0)

使用java时,spinner使用适配器。您可以将自定义对象传递给该适配器。如果我没记错的话,为每个项目调用class MySpinnerDataItem { String title; int number; } 方法。

https://example.com/_vti_bin/exampleService/exampleService.svc/Categories?
$filter=Products/any(x:x/Status eq toupper('DELETED'))&
$select=ID,Products/Status,Products/Title&
$expand=Products

答案 1 :(得分:0)

如果我理解正确的话。您希望将“heading23”等字符串拆分为“heading”和“23”。

如果是这样,您可以利用Regular Expression。在C#中,您可以使用类Regex

string str = "test123";
Regex reg = new Regex(@"\d+");//"\d" means digits "+" means match one or more
Match match=reg.Match(str);
if (match.Success)
{
    string numberStr =match.Value;//value="123"
    int number = int.Parse(numberStr);//number=123
    var title = str.Replace(numberStr, "");//title="test"
}
相关问题