java 调用图灵接口_图灵机器人(问答机器人)API调用示例

先上图:

86257921ea17961265a210bb3913bfc9.png

说下大致实现的步骤:

1、首先使用了聚合数据的sdk,这样免费使用的数目可以多一些

2、使用gson来解析json数据

3、使用ListView来显示数据

那,先将布局贴上来

数据部分 机器人和人布局类似 只粘一个

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:id="@+id/robot_time"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:textColor="#cccccc"

android:gravity="center_horizontal"

android:text="2015-8-23 17:37:23" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="horizontal" >

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="vertical" >

android:layout_width="50dp"

android:layout_height="50dp"

android:src="@drawable/icon" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:gravity="center_horizontal"

android:text="小桂子"

android:textSize="12sp" />

android:id="@+id/robot_msg"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="5dp"

android:background="@drawable/chatfrom_bg_normal"

android:gravity="center"

android:layout_gravity="bottom"

android:text="你好,我是小桂子" />

然后是主布局:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context="com.example.juheapi.MainActivity" >

android:id="@+id/titleBar"

android:layout_width="fill_parent"

android:layout_height="50dp"

android:layout_alignParentTop="true"

android:background="@drawable/title_bar" >

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerInParent="true"

android:text="小桂子 贱贱哒"

android:textColor="#eeeeee"

android:textStyle="bold" />

android:id="@+id/listView"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值