【问题标题】:How to request movie data from Rotten Tomatoes using their JSON API Using TextWatcher如何使用 Rotten Tomatoes 的 JSON API 使用 TextWatcher 请求电影数据
【发布时间】:2016-01-22 19:43:58
【问题描述】:
在我的 Android 应用程序中,我有一个 EditText、一个 Button、一个 RecyclerView 和 Adapter。当我在 EditText 字段中或在 上键入电影名称时,我希望 RecyclerView 填充来自烂番茄网站的与我在 EditText 字段中输入的内容相匹配的电影名称。
但我不知道如何使用 Rotten Tomatoes JSON API 通过 TextWatcher 获取电影数据。我该怎么做?或者有没有更好的想法?
我已经为此苦苦挣扎了好几天..
请给我一个例子。
【问题讨论】:
标签:
android
json
search
textwatcher
rotten-tomatoes
【解决方案1】:
简单:)
http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=[your_api_key]&q=[your_escaped_query]&page_limit=1
通过您喜欢的任何方式查询此 JSON 端点。 textwatcher 将返回一个字符,但我建议您每次都提取该字段的全部内容。然后对字符串设置一个查询。
示例 JSON 字符串下载:
Downloading a website to a string