android– 如何使用Fabric的AppCompatActivity获取时间轴?

android– 如何使用Fabric的AppCompatActivity获取时间轴?,第1张

概述我正在关注fabric’sdocumentation以获得时间表.如果我根据他们的指令使用ListActivity,它工作正常.但我想添加自己的工具栏,所以我使用了AppCompatActivity.这是我的java文件的一部分:publicclassTimelineActivityextendsAppCompatActivity{publicstaticfinalStringQU

我正在关注fabric’s documentation以获得时间表.如果我根据他们的指令使用ListActivity,它工作正常.但我想添加自己的工具栏,所以我使用了AppCompatActivity.这是我的java文件的一部分:

public class TimelineActivity extends AppCompatActivity{public static final String query = "query";@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentVIEw(R.layout.activity_timeline);    Toolbar toolbar = (Toolbar)findVIEwByID(R.ID.toolbar);    setSupportActionbar(toolbar);    getSupportActionbar().setdisplayHomeAsUpEnabled(true);    SearchTimeline searchTimeline = new SearchTimeline.Builder()            .query(getIntent().getStringExtra(query))            .build();    final TweetTimelinelistadapter adapter = new TweetTimelinelistadapter.Builder(this)            .setTimeline(searchTimeline)            .build();    ListVIEw tweetList = (ListVIEw)findVIEwByID(R.ID.tweet_List);    tweetList.setAdapter(adapter);}

这是我的xml:

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:tools="http://schemas.androID.com/tools"    xmlns:app="http://schemas.androID.com/apk/res-auto"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    tools:context=".TimelineActivity">    <androID.support.design.Widget.AppbarLayout        androID:ID="@+ID/appbar"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:theme="@style/themeOverlay.AppCompat.Dark.Actionbar">        <androID.support.v7.Widget.Toolbar            androID:ID="@+ID/toolbar"            androID:layout_wIDth="match_parent"            androID:layout_height="?attr/actionbarSize"            app:layout_scrollFlags="scroll|enteralways"/>    </androID.support.design.Widget.AppbarLayout>    <linearLayout        androID:layout_below="@ID/appbar"        androID:orIEntation="vertical"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        app:layout_behavior="@string/appbar_scrolling_vIEw_behavior">        <TextVIEw androID:ID="@ID/androID:empty"            androID:layout_wIDth="match_parent"            androID:layout_height="match_parent"            androID:gravity="center_horizontal|center_vertical"            androID:text="Please wait . . ."/>        <ListVIEw androID:ID="@+ID/tweet_List"            androID:layout_wIDth="match_parent"            androID:layout_height="0dp"            androID:layout_weight="1"            androID:divIDer="#e1e8ed"            androID:divIDerHeight="1dp"            androID:drawSelectorOntop="false"/>    </linearLayout></relativeLayout>

问题是,它没有显示任何结果.我被困在“请等待……” TextVIEw中.

解决方法:

我自己回答了,因为我没有扩展ListActivity,我需要使用setEmptyVIEw()手动添加ID = empty的TextVIEw.

    TextVIEw emptyText = (TextVIEw)findVIEwByID(androID.R.ID.empty);    ListVIEw tweetList = (ListVIEw)findVIEwByID(R.ID.tweet_List);    tweetList.setEmptyVIEw(emptyText);    tweetList.setAdapter(adapter);
总结

以上是内存溢出为你收集整理的android – 如何使用Fabric的AppCompatActivity获取时间轴?全部内容,希望文章能够帮你解决android – 如何使用Fabric的AppCompatActivity获取时间轴?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1107922.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存