【问题标题】:Eclipse Switch Button value Json url Read/WriteEclipse 开关按钮值 Json url 读/写
【发布时间】:2013-12-17 05:19:47
【问题描述】:
{'outlet1':'on' , 'outlet2':'off' , 'outlet3':'on'}

[http://192.168.2.200:5555/getJsonData.json][1]在“Outlet1”中规定从android按钮中读出的值可以在切换到“ON”和“OFF”值时造成。

【问题讨论】:

  • 那你想做什么?
  • "outlet2 = ON",我想切换按钮值“ON”
  • yourSwitch.setChecked(true);
  • 我需要 Java 代码方面的帮助。我将用于家庭自动化系统。我需要在 json 上打印并读出。但不知何故我做不到。

标签: android json eclipse switch-statement outlet


【解决方案1】:

您可以轻松阅读json 关注this tutorial 编写时很容易生成和上传 json,但您需要使用简单的服务从服务器端提交它

【讨论】:

  • 我试过了,但是读取的JSON键值中的http地址和值,按钮不操作。 Http 地址“内容类型应用程序/json”。 Eclipse android资料很弱,能帮忙吗?
【解决方案2】:

我也想做android下面的操作:

<script> function updateControls() { $.getJSON('/status.json', function (json) { $.each(json, function (key, value) { $('#' + key).val(value).slider('refresh'); }); }); } $('select').on('change', function (event) { element = event.target.id; if (element.substr(0, 6) == 'outlet') { eleid = element.substr(6, 2); } else { eleid = 0; } command = event.target.value; $.get('/cmd', { 'eleid': eleid, 'cmd': command }); }); $(document).ready(function () { updateControls(); }); </script>

【讨论】:

    【解决方案3】:

    Json 设法读取。但是当我想发送 POST 时手动打开或关闭。

    Switch = ON  [POST value : http://192.168.2.200/State?eleid=10&cmd=on  ]
    Switch = OFF [POST value : http://192.168.2.200/State?eleid=10&cmd=off ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 2012-11-20
      • 1970-01-01
      • 1970-01-01
      • 2015-02-18
      • 2018-06-23
      • 1970-01-01
      相关资源
      最近更新 更多