1

我有项目中我想创建标签视图,其中从json 生成的所有标签取决于json。 和标签视图的内容是列表视图,再次列表视图数据来自json。动态标签生成与动态内容

这里我提供我的JSON文件基于JSON中

和标签的内容区域标签创建

“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”:”” 
       } 
} 

此选项卡是基于区域即标题,描述。
所以我很困惑如何创建标签和如何在不同的标签预先添加内容

感谢

+0

我不知道是否[这](HTTP://计算器.com/questions/14251003 /试图生成选项卡和动态他们的意见)可以给你一些提示。和[这](http://stackoverflow.com/a/15417844/2683275)也 –

回答

1

试试这个:

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); 
     } 
    });