【问题标题】:Search Twitter Users in app在应用程序中搜索 Twitter 用户
【发布时间】:2016-11-02 02:43:27
【问题描述】:

我已经在我的应用程序中使用 Fabric 将 Twitter API 集成到我的项目中,并拥有一个重定向到空白活动的 Twitter 登录。我想在此活动的顶部有一个搜索栏,用于搜索 Twitter 用户(仅限用户)。我该怎么做呢?

【问题讨论】:

  • 您可以访问 API,那么您是否阅读了文档以了解如何搜索用户?
  • 我使用fabric将twitter套件安装到android studio中,但我相信为了使用REST api我需要使用改造或其他东西(我可能完全错了),所以我'我看看是否可以使用该套件(在这方面有一些困难,哈哈)。

标签: java android twitter-fabric


【解决方案1】:

您需要查询搜索推特。请参阅下面的示例。

私有静态最终字符串 SEARCH_QUERY = "almounir"; //用户名或Hshgtag

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout. activity_main);

ListView lv = (ListView) findViewById(R.id.list);
//lv.setEmptyView(findViewById(R.id.loading)); d'ont forget to add loading pic 

SearchTimeline searchTimeline = new SearchTimeline.Builder().query(SEARCH_QUERY).build();

final TweetTimelineListAdapter timelineAdapter = new TweetTimelineListAdapter(this, searchTimeline);

lv.setAdapter(timelineAdapter);
}

另一个样本tutorial source code sample

【讨论】:

  • 谢谢!这是一个很好的开始。我的问题是,如何才能使结果只有用户名?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-21
  • 2012-04-24
  • 1970-01-01
  • 2012-05-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多