Android 使用动态内容生成动态选项卡
我有一个项目,我想在其中创建选项卡视图,其中所有选项卡都是从json生成的 依赖于json。 选项卡视图的内容是列表视图,列表视图数据同样来自json 这里我提供了我的json文件Android 使用动态内容生成动态选项卡,android,json,android-tabhost,android-tabs,android-tabactivity,Android,Json,Android Tabhost,Android Tabs,Android Tabactivity,我有一个项目,我想在其中创建选项卡视图,其中所有选项卡都是从json生成的 依赖于json。 选项卡视图的内容是列表视图,列表视图数据同样来自json 这里我提供了我的json文件 “checks”{“check”:{ “ref”:”1”, “area”:”In Cab”, “title”:”Condition of windscreen”, “des
“checks”{“check”:{
“ref”:”1”,
“area”:”In Cab”,
“title”:”Condition of windscreen”,
“description”:”Check there are no cracks, that the windscreen is clean and not greasy.”,
“controlType”:”Check”,
“checkResult”:””,
“checkValue”:””
},
“check”:{
“ref”:”2”,
“area”:”External”,
“title”:”Windscreen wipers”,
“description”:”Check the wiper surface is smooth and not cut and the wiper touches the screen on its full length.”,
“controlType”:”Check”,
“checkResult”:””,
“checkValue”:””
},
“check”:{
“ref”:”3”,
“area”:”Input”,
“title”:”Registration”,
“description”:”Enter the registration number for the vehicle.”,
“controlType”:”TEXT”,
“checkResult”:””,
“checkValue”:””
},
“check”:{
“ref”:”4”,
“area”:”Input”,
“title”:”Mileage”,
“description”:”Enter the mileage for the vehicle.”,
“controlType”:”NUMBER”,
“checkResult”:””,
“checkValue”:””
},
“check”:{
“ref”:”5”,
“area”:”Input”,
“title”:”Tacho Expiry Date”,
“description”:”enter the tacho expiry date.”,
“controlType”:”DATE”,
“checkResult”:””,
“checkValue”:””
},
“check”:{
“ref”:”6”,
“area”:”Input”,
“title”:”Warning light colour”,
“description”:”Enter the warning light colour.”,
“controlType”:”SELECT”,
“selectValues”:”’Red, ‘Amber’,’’Green”,
“checkResult”:””,
“checkValue”:””
}
}
此处选项卡是基于json中的区域标记创建的
选项卡的内容基于区域,即标题、说明。因此,我对如何创建选项卡以及如何在不同的选项卡中添加内容感到困惑 提前感谢试试这个:
btnAddTab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TabHost.TabSpec spec = tabHost.newTabSpec("Tab"+i);
spec.setContent(new TabHost.TabContentFactory() {
@Override
public View createTabContent(String tag) {
return new AnalogClock(MainActivity.this);
}
});
spec.setIndicator("Clock");
tabHost.addTab(spec);
}
});
我不知道能否给你一些提示。而且