sah*_*ahu 5 twitter android android-layout twitter-fabric
我使用Twitter的android sdk开发应用程序.在给定的sdk中有一个用于显示推文的CompactTweetView,但是没有用于显示转推计数的字段.要显示推文我正在使用sdk中提供的TweetViewAdapter.
现在我想在每条推文下面显示转推计数.我怎样才能实现目标?我是否必须在ListView中的每个条目之后添加单独的行以显示转发计数,或者是否有任何其他方式可以扩展CompactTweetView以包括转推计数.另一种方法是我使用一个空的LinearLayout并在每个CompactTweetView之后为转推计数视图添加一行.两种情况下的表现如何?
ListView(如果可能的话怎么做?)
使用备用CompactTweetView和转推计数视图清空LinearLayout.
如果有任何不清楚的地方,请询问更多信息.谢谢.
使用带有TweetViewAdapter的ListView的我的Twitter应用程序的当前状态.我想在每一行后显示转推计数.

在fabric iu sdks上搜索tw__tweet_compact.xml或tw__tweet.xml布局。复制到资源布局中。不要更改名称。添加您的自定义 Texview 以显示转发计数。\n这是我的自定义 tw__tweet_compact.xml
\n\n<RelativeLayout\nxmlns:android="http://schemas.android.com/apk/res/android"\nxmlns:tools="http://schemas.android.com/tools"\nandroid:id="@+id/tw__tweet_view"\nstyle="@style/tw__CompactTweetContainer">\n\n<TextView\n android:id="@+id/tw__tweet_retweeted_by"\n style="@style/tw__TweetRetweetedBy.Compact"\n android:layout_alignLeft="@+id/tw__author_attribution"\n tools:text="retweeted by" />\n\n<ImageView\n android:id="@+id/tw__tweet_author_avatar"\n style="@style/tw__TweetAvatar.Compact"\n android:layout_below="@id/tw__tweet_retweeted_by"\n tools:background="@color/tw__tweet_media_preview_bg_color"\n tools:ignore="ContentDescription" />\n\n<!--Name and timestamp don\'t ellipsize, but @username in the middle does ellipsize-->\n<LinearLayout\n android:id="@+id/tw__author_attribution"\n style="@style/tw__CompactAttributionLine"\n android:layout_below="@id/tw__tweet_retweeted_by"\n android:layout_toEndOf="@id/tw__tweet_author_avatar"\n android:layout_toRightOf="@id/tw__tweet_author_avatar">\n\n <TextView\n android:id="@+id/tw__tweet_author_full_name"\n style="@style/tw__TweetFullName.Compact"\n tools:text="Jack" />\n\n <TextView\n android:id="@+id/tw__tweet_author_screen_name"\n style="@style/tw__TweetScreenName.Compact"\n tools:text="@jack" />\n\n <TextView\n android:id="@+id/tw__tweet_timestamp"\n style="@style/tw__TweetTimestamp.Compact"\n tools:text="\xe2\x80\xa2 03/21/2006" />\n\n</LinearLayout>\n\n<ImageView\n android:id="@+id/tw__twitter_logo"\n style="@style/tw__TwitterLogo.Compact"\n android:layout_alignParentEnd="true"\n android:layout_alignParentRight="true"\n android:layout_below="@id/tw__tweet_retweeted_by"\n tools:ignore="ContentDescription" />\n\n<com.twitter.sdk.android.tweetui.internal.util.AspectRatioImageView\n android:id="@+id/tw__tweet_media"\n style="@style/tw__TweetMedia.Compact"\n android:layout_below="@id/tw__author_attribution"\n android:layout_toEndOf="@id/tw__tweet_author_avatar"\n android:layout_toRightOf="@id/tw__tweet_author_avatar"\n tools:ignore="ContentDescription" />\n\n<TextView\n android:id="@+id/tw__tweet_text"\n style="@style/tw__TweetText.Compact"\n android:layout_below="@id/tw__tweet_media"\n android:layout_toEndOf="@id/tw__tweet_author_avatar"\n android:layout_toRightOf="@id/tw__tweet_author_avatar"\n tools:text="just setting up my twttr" />\n\n<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"\n xmlns:tools="http://schemas.android.com/tools"\n android:id="@+id/rtwfavLayout"\n android:layout_width="match_parent"\n android:layout_height="36dp"\n android:layout_below="@+id/tw__tweet_text"\n android:layout_toEndOf="@+id/tw__tweet_author_avatar"\n android:layout_toRightOf="@+id/tw__tweet_author_avatar"\n android:orientation="horizontal">\n\n <ImageView\n android:layout_width="15dp"\n android:layout_height="15dp"\n android:layout_marginBottom="2dp"\n android:layout_marginRight="2dp"\n android:layout_marginTop="11dp"\n android:scaleType="fitCenter"\n android:src="@drawable/tw__ic_retweet_light" />\n\n <TextView\n android:id="@+id/rtwtxt"\n android:layout_width="80dp"\n android:layout_height="wrap_content"\n android:layout_marginBottom="2dp"\n android:layout_marginTop="11dp"\n android:singleLine="true"\n\n\n />\n\n <ImageView\n android:layout_width="15dp"\n android:layout_height="15dp"\n android:layout_marginBottom="2dp"\n android:layout_marginLeft="20dp"\n android:layout_marginRight="2dp"\n android:layout_marginTop="11dp"\n android:scaleType="fitCenter"\n android:src="@drawable/favourite" />\n\n <TextView\n android:id="@+id/favtxt"\n android:layout_width="wrap_content"\n android:layout_height="wrap_content"\n android:layout_marginBottom="2dp"\n android:layout_marginTop="11dp"\n android:drawablePadding="5dp"\n android:singleLine="true" />\n\n</LinearLayout>\n\n</RelativeLayout>\nRun Code Online (Sandbox Code Playgroud)\n\n修改您的推文适配器后。在getView方法中添加TextView,并在TextView中设置转发次数。收藏夹的数量效果不佳。只显示自己最喜欢的推文。不显示其他用户最喜欢的推文。
\n\n public class TweetAdapter extends TweetTimelineListAdapter {\n public TweetAdapter(Context context, Timeline<Tweet> timeline) {\n super(context, timeline);\n }\n\n @Override\n public View getView(final int position, View convertView, ViewGroup parent) {\n final View view = super.getView(position, convertView, parent);\n CompactTweetView compactTweetView = (CompactTweetView) view;\n\n TextView txtfav = (TextView) compactTweetView.findViewById(R.id.favtxt);\n\n TextView txtrtw = (TextView) compactTweetView.findViewById(R.id.rtwtxt);\n\n\n if (compactTweetView.getTweet().retweetedStatus != null) {\n txtfav.setText(String.valueOf(compactTweetView.getTweet().retweetedStatus.favoriteCount));\n if (txtfav.getText().equals("null")) {\n txtfav.setText(String.valueOf(compactTweetView.getTweet().favoriteCount));\n }\n txtrtw.setText(String.valueOf(compactTweetView.getTweet().retweetedStatus.retweetedStatus));\n if (txtrtw.getText().equals("null")) {\n txtrtw.setText(String.valueOf(compactTweetView.getTweet().retweetCount));\n }\n } else {\n txtfav.setText(String.valueOf(compactTweetView.getTweet().favoriteCount));\n txtrtw.setText(String.valueOf(compactTweetView.getTweet().retweetCount));\n }\n\n return compactTweetView;\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我认为这种方式更容易。问候
\n| 归档时间: |
|
| 查看次数: |
862 次 |
| 最近记录: |