// CustomAdapter.java
{
"slider": [
{
"name": "Demo Event",
"images": "uploads\/event\/demo.png",
"location": "Ernakulam"
},
{
"name": "cfghedrgyedyg",
"images": "uploads\/event\/Array466.jpg",
"location": "dfgred"
},
{
"name": "Demo",
"images": "uploads\/event\/Array698.jpg",
"location": "Thodupuzha"
},
{
"name": "Event",
"images": "uploads\/event\/Array745.jpg",
"location": "Angamaly"
},
{
"name": "ghtrfhy",
"images": "uploads\/event\/Array350.jpg",
"location": "Thodupuzha"
}
]
}
我的json结果是,
int[] imageId = {R.drawable.slider1, R.drawable.slider2};
我的问题是,如何使用服务器中的值更改String[] caption = { "1", "2" };
和 private async Task SaveSettings(Settings settings)
{
var folder = Windows.Storage.ApplicationData.Current.LocalFolder;
var options = Windows.Storage.CreationCollisionOption.ReplaceExisting;
var file = await folder.CreateFileAsync("Settings.XML", options);
try
{
XmlSerializer SerializerObj = new XmlSerializer(typeof(Settings));
SerializerObj.Serialize(await file.OpenStreamForWriteAsync(), settings);
}
catch
{
// handle any kind of exceptions
}
}
中的值。即,使用JSON。
是否可以实现这一点。 我尝试了很多。但没有成功。
提前致谢。
答案 0 :(得分:2)
像这样创建一个商业实体/类
public class ImageDetails()
{
public int ImageId;
public String Caption;
}
创建此类的列表作为对象并填充详细信息
List<ImageDetails> imgDetails=new ArrayList<ImageDetails>();
ImageDetails img1=new ImageDetails();
img1.ImageId=1;
img1.Caption="Caption";
更改适配器的构造函数以接受此列表
public CustomAdapter(Context context,List<ImageDetails> imageDetails){
this.context = context;
this.ImageDetails=imageDetails;
}
最后在getview
TextView textView = (TextView) viewItem.findViewById(R.id.textView1);
textView.setText(ImageDetails.get(position).Caption);