Listview不支持加載輸入類控件,動態創建控件去代替listview的示例demo

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Hello World</title>
</head>
<body>
  <div id="navDiv" width="100%" height="50" backgroundColor="#ee5121"   >
      <div width="100%" height="50" vAlign="middle" hAlign="center" >
      </div>
   </div> 
   
  <div   width="100%" height="100%" layout="VBox"  overflow="y" > 
       <div id="privatewv" width="100%" height="725" layout="VBox" >

         </div>
  </div>
  <input type="button" value="獲取第一個輸入框的值" onClick="getValue1"/>
</body>
<script> 

  var objArr = [{"title":"商品:水泥","price":"價格:1000元/噸","time":"更新時間:2016-06-05"},
      {"title":"商品:鋼材","price":"價格:4000元/噸","time":"更新時間:2016-06-04"},
      {"title":"商品:煤","price":"價格:3000元/噸","time":"更新時間:2016-06-06"},
      {"title":"商品:石油","price":"價格:2000元/噸","time":"更新時間:2016-06-03"},
      {"title":"商品:石油2","price":"價格:2300元/噸","time":"更新時間:2016-06-09"}];
  paramInfo(objArr);
  
  var paramArr;
  
  function paramInfo(obj) {
    paramArr = [];
    
    //在for循環裏面動態創建界面控件
      for (var i = 0; i < obj.length; i++) {
        var privateyield=new Emp.Panel({
        "id" : "privateyield",
        "width" : "100%",
        "height" : "145",
        "layout" : "VBox"
      });
      
      eval(' title_'+i+' = new Emp.Label({"id" : "title_'+i+'","value" : "'+obj[i].title+ '","fontSize" : "14","marginLeft":"30","height":"30"})');
      
      eval(' price_'+i+' = new Emp.Label({"id" : "price_'+i+'","value" : "'+obj[i].price+ '","fontSize" : "14","marginLeft":"30","height":"30"})');
      
      eval(' time_'+i+' = new Emp.Label({"id" : "time_'+i+'","value" : "'+obj[i].time+ '","fontSize" : "14","marginLeft":"30","height":"30"})');
      
      eval(' text_'+i+' = new Emp.Text({"id" : "text_'+i+'","value" : "","fontSize" : "14","marginLeft":"30","height":"45",width:"200"})');

      
      eval(' line_'+i+' = new Emp.Panel({"height":"1","width":"100%","backgroundColor":"#4A4A4A","marginTop":"9"})');
      
      privateyield.add(eval('title_'+i));
      privateyield.add(eval('price_'+i));
      privateyield.add(eval('time_'+i));
        privateyield.add(eval('text_'+i));
        privateyield.add(eval('line_'+i));
        privatewv.add(privateyield);
          }
     
  }
  
  function getValue1(){
     text_0.setValue("sssssss")
     alert(eval(text_0).getValue())
  }
  
</script>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章