- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是将值放入 ArrayList 的代码,我无法用“,”分割数组列表。有人可以帮助我如何完成这项任务吗?
spinnerArrayList = new ArrayList<String>();
spinnerArrayList.add(menuFieldInstance.getFieldValues());
Log.i("spinnerArrayList",""+spinnerArrayList);
//for(int j=0;j<spinnerArrayList.size();j++)
//{
Log.i("spinnerArrayList after splitting ,",""+spinnerArrayList.get(0).split(","));
//}
这里是Spinner ArrayList和SpinnerArrayList拆分后的Logcat........................
02-10 22:00:48.285: I/spinnerArrayList(19378): [0100~Avon & Somerset,0200~Bedfordshire,0300~Cambridgeshire,0400~Cheshire,0500~City of London,0600~Cleveland,0700~Cumbria,0800~Derbyshire,0900~Devon & Cornwall,1000~Dorset,1100~Durham,1200~Essex,1300~Gloucestershire,1400~Greater Manchester,1500~Hampshire,1600~Hertfordshire,1700~Humberside,1800~Kent,1900~Lancashire,2000~Leicestershire,2100~Linconshire,2200~Merseyside,2300~Metropolitan,2400~Norfolk,2500~Northamptonshire,2600~Northumbria,2700~North Yorkshire,2800~Nottinghamshire,2900~South Yorkshire,3000~Staffordshire,3100~Suffolk,3200~Surrey,3300~Sussex,3400~Thames Valley,3500~Warwickshire,3600~West Mercia,3700~West Midlands,3800~West Yorkshire,3900~Wiltshire,4000~Dyfed,4100~Gwent,4200~North Wales,4300~South Wales,4400~Royal Ulster,4500~Strathclyde,4600~Central Scotland,4700~Dumfries and Galloway,4800~Fife,4900~Grampian,5000~Lothian and Borders,5100~Northern Scotland,5200~Tayside,5300~Gurnsey,5400~States of Jersey,5500~Isle of Man,NO~No Police Response,THAM~THAMES VALLEY,WEST~WEST MIDLANDS POLICE,5600~Buckinghamshire] 02-10 22:00:48.285: I/spinnerArrayList after splitting ,(19378): [Ljava.lang.String;@41b9a498
最佳答案
// try to print this way then you getting actual value at index becz your try to print String[] object rather each index value so do this way
spinnerArrayList = new ArrayList<String>();
spinnerArrayList.add("");
for (int i=0;i<spinnerArrayList.size();i++){
String[] splitedValue = spinnerArrayList.get(i).split(",");
for (int j=0;j<splitedValue.length;j++){
Log.i(i+" at ArrayIndex "+j+" at splitedIndex Value is >> ",splitedValue[j]);
String[] splitedValue1 = splitedValue[j].split("~");
if(splitedValue1.length==1){
continue;
}
for (int k=0;k<splitedValue1.length;k++){
Log.i(j+" at splitedIndex "+k+" at splited1Index Value is >> ",splitedValue1[k]);
}
}
}
关于java - 如何在Android中使用JAVA拆分ArrayList?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21670258/
我是一名优秀的程序员,十分优秀!