新浪博客首页微博打开刷新首页那个界面,不能刷新出以前看的内容,如果没有新内容,就直接显示关注别人

从国外成功案例看新浪微博时间轴广告的不足之处_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
从国外成功案例看新浪微博时间轴广告的不足之处
上传于||文档简介
&&在​今​天​中​午​刷​微​博​的​部​分​用​户​可​能​会​注​意​到​,​在​刷​新​首​页​之​后​,​微​博​的​时​间​轴​中​出​现​了​一​条​置​顶​的​由​新​浪​微​博​官​方​账​户​“​热​门​微​博​排​行​榜​”​发​布​的​内​容​,​其​中​的​内​容​是​“​微​博​控​们​,​你​们​还​在​不​断​地​刷​新​再​刷​新​吗​?​如​果​你​没​有​那​么​多​时​间​刷​微​博​,
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
你可能喜欢Android新浪微博下拉刷新(最新消息显示在最上面)
字体:[ ] 类型:转载 时间:
查看最新消息要用到类似新浪微博下拉刷新,想必这个功能很多的朋友都会使用吧,下面与大家分享下具体的实现方法,感兴趣的朋友可以参考下哈
查看最新消息要用到类似新浪微博下拉刷新 功能!把最新的消息显示在最上面! 代码如下: PullToRefreshListView类代码
代码如下: package com.markupartist.android. import java.util.D import com.markupartist.android.example.pulltorefresh.R; import android.content.C import android.util.AttributeS import android.util.L import android.view.LayoutI import android.view.MotionE import android.view.V import android.view.ViewG import android.view.animation.LinearI import android.view.animation.RotateA import android.widget.AbsListV import android.widget.AbsListView.OnScrollL import android.widget.BaseA import android.widget.ImageV import android.widget.LinearL import android.widget.ListV import android.widget.ProgressB import android.widget.TextV public class PullToRefreshListView extends ListView implements OnScrollListener { private static final String TAG = "listview"; private final static int RELEASE_To_REFRESH = 0; private final static int PULL_To_REFRESH = 1; private final static int REFRESHING = 2; private final static int DONE = 3; private final static int LOADING = 4; // 实际的padding的距离与界面上偏移距离的比例 private final static int RATIO = 3; private LayoutI private LinearLayout headV private TextView tipsT private TextView lastUpdatedTextV private ImageView arrowImageV private ProgressBar progressB private RotateA private RotateAnimation reverseA // 用于保证startY的值在一个完整的touch事件中只被记录一次 private boolean isR private int headContentW private int headContentH private int startY; private int firstItemI
private boolean isB private OnRefreshListener refreshL private boolean isR public PullToRefreshListView(Context context) { super(context); init(context); } public PullToRefreshListView(Context context, AttributeSet attrs) { super(context, attrs); init(context); } private void init(Context context) { setCacheColorHint(context.getResources().getColor(android.R.color.transparent)); inflater = LayoutInflater.from(context); headView = (LinearLayout) inflater.inflate(R.layout.pull_to_refresh_header, null); arrowImageView = (ImageView) headView .findViewById(R.id.head_arrowImageView); arrowImageView.setMinimumWidth(70); arrowImageView.setMinimumHeight(50); progressBar = (ProgressBar) headView .findViewById(R.id.head_progressBar); tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView); lastUpdatedTextView = (TextView) headView .findViewById(R.id.head_lastUpdatedTextView); measureView(headView); headContentHeight = headView.getMeasuredHeight(); headContentWidth = headView.getMeasuredWidth(); headView.setPadding(0, -1 * headContentHeight, 0, 0); headView.invalidate(); Log.v("size", "width:" + headContentWidth + " height:" + headContentHeight); addHeaderView(headView, null, false); setOnScrollListener(this); animation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(new LinearInterpolator()); animation.setDuration(250); animation.setFillAfter(true); reverseAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); reverseAnimation.setInterpolator(new LinearInterpolator()); reverseAnimation.setDuration(200); reverseAnimation.setFillAfter(true); state = DONE; isRefreshable = } public void onScroll(AbsListView arg0, int firstVisiableItem, int arg2, int arg3) { firstItemIndex = firstVisiableI } public void onScrollStateChanged(AbsListView arg0, int arg1) { } public boolean onTouchEvent(MotionEvent event) { firstItemIndex=getFirstVisiblePosition(); if (isRefreshable) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (firstItemIndex == 0 && !isRecored) { isRecored = startY = (int) event.getY(); Log.v(TAG, "在down时候记录当前位置‘"); }
case MotionEvent.ACTION_UP: if (state != REFRESHING && state != LOADING) { if (state == DONE) { // 什么都不做 } if (state == PULL_To_REFRESH) { state = DONE; changeHeaderViewByState(); Log.v(TAG, "由下拉刷新状态,到done状态"); } if (state == RELEASE_To_REFRESH) { state = REFRESHING; changeHeaderViewByState(); onRefresh(); Log.v(TAG, "由松开刷新状态,到done状态"); } } isRecored = isBack =
case MotionEvent.ACTION_MOVE: int tempY = (int) event.getY(); if (!isRecored && firstItemIndex == 0) { Log.v(TAG, "在move时候记录下位置"); isRecored = startY = tempY; } if (state != REFRESHING && isRecored && state != LOADING) { // 保证在设置padding的过程中,当前的位置一直是在head,否则如果当列表超出屏幕的话,当在上推的时候,列表会同时进行滚动 // 可以松手去刷新了 if (state == RELEASE_To_REFRESH) { setSelection(0); // 往上推了,推到了屏幕足够掩盖head的程度,但是还没有推到全部掩盖的地步 if (((tempY - startY) / RATIO & headContentHeight) && (tempY - startY) & 0) { state = PULL_To_REFRESH; changeHeaderViewByState(); Log.v(TAG, "由松开刷新状态转变到下拉刷新状态"); } // 一下子推到顶了 else if (tempY - startY &= 0) { state = DONE; changeHeaderViewByState(); Log.v(TAG, "由松开刷新状态转变到done状态"); } // 往下拉了,或者还没有上推到屏幕顶部掩盖head的地步 else { // 不用进行特别的操作,只用更新paddingTop的值就行了 } } // 还没有到达显示松开刷新的时候,DONE或者是PULL_To_REFRESH状态 if (state == PULL_To_REFRESH) { setSelection(0); // 下拉到可以进入RELEASE_TO_REFRESH的状态 if ((tempY - startY) / RATIO &= headContentHeight) { state = RELEASE_To_REFRESH; isBack = changeHeaderViewByState(); Log.v(TAG, "由done或者下拉刷新状态转变到松开刷新"); } // 上推到顶了 else if (tempY - startY &= 0) { state = DONE; changeHeaderViewByState(); Log.v(TAG, "由DOne或者下拉刷新状态转变到done状态"); } } // done状态下 if (state == DONE) { if (tempY - startY & 0) { state = PULL_To_REFRESH; changeHeaderViewByState(); } } // 更新headView的size if (state == PULL_To_REFRESH) { headView.setPadding(0, -1 * headContentHeight + (tempY - startY) / RATIO, 0, 0); } // 更新headView的paddingTop if (state == RELEASE_To_REFRESH) { headView.setPadding(0, (tempY - startY) / RATIO - headContentHeight, 0, 0); } }
} } return super.onTouchEvent(event); } // 当状态改变时候,调用该方法,以更新界面 private void changeHeaderViewByState() { switch (state) { case RELEASE_To_REFRESH: arrowImageView.setVisibility(View.VISIBLE); progressBar.setVisibility(View.GONE); tipsTextview.setVisibility(View.VISIBLE); lastUpdatedTextView.setVisibility(View.VISIBLE); arrowImageView.clearAnimation(); arrowImageView.startAnimation(animation); tipsTextview.setText("松开刷新"); Log.v(TAG, "当前状态,松开刷新");
case PULL_To_REFRESH: progressBar.setVisibility(View.GONE); tipsTextview.setVisibility(View.VISIBLE); lastUpdatedTextView.setVisibility(View.VISIBLE); arrowImageView.clearAnimation(); arrowImageView.setVisibility(View.VISIBLE); // 是由RELEASE_To_REFRESH状态转变来的 if (isBack) { isBack = arrowImageView.clearAnimation(); arrowImageView.startAnimation(reverseAnimation); tipsTextview.setText("下拉刷新"); } else { tipsTextview.setText("下拉刷新"); } Log.v(TAG, "当前状态,下拉刷新");
case REFRESHING: headView.setPadding(0, 0, 0, 0); progressBar.setVisibility(View.VISIBLE); arrowImageView.clearAnimation(); arrowImageView.setVisibility(View.GONE); tipsTextview.setText("正在刷新..."); lastUpdatedTextView.setVisibility(View.VISIBLE); Log.v(TAG, "当前状态,正在刷新...");
case DONE: headView.setPadding(0, -1 * headContentHeight, 0, 0); progressBar.setVisibility(View.GONE); arrowImageView.clearAnimation(); arrowImageView.setImageResource(R.drawable.ic_pulltorefresh_arrow); tipsTextview.setText("下拉刷新"); lastUpdatedTextView.setVisibility(View.VISIBLE); Log.v(TAG, "当前状态,done");
} } public void setOnRefreshListener(OnRefreshListener refreshListener) { this.refreshListener = refreshL isRefreshable = } public interface OnRefreshListener { public void onRefresh(); } public void onRefreshComplete() { state = DONE; lastUpdatedTextView.setText("最近更新:" + new Date().toLocaleString()); changeHeaderViewByState(); } private void onRefresh() { if (refreshListener != null) { refreshListener.onRefresh(); } } // 此方法直接照搬自网络上的一个下拉刷新的demo,此处是“估计”headView的width以及height private void measureView(View child) { ViewGroup.LayoutParams p = child.getLayoutParams(); if (p == null) { p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width); int lpHeight = p. int childHeightS if (lpHeight & 0) { childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY); } else { childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } child.measure(childWidthSpec, childHeightSpec); } public void setAdapter(BaseAdapter adapter) { lastUpdatedTextView.setText("最近更新:" + new Date().toLocaleString()); super.setAdapter(adapter); } }
activity调用代码
代码如下: package com.markupartist.android.example. import java.util.A import java.util.LinkedL import android.app.ListA import android.os.AsyncT import android.os.B import android.widget.ArrayA import com.markupartist.android.widget.PullToRefreshListV import com.markupartist.android.widget.PullToRefreshListView.OnRefreshL public class PullToRefreshActivity extends ListActivity { private LinkedList&String& mListI /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pull_to_refresh); // Set a listener to be invoked when the list should be refreshed. ((PullToRefreshListView) getListView()).setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { // Do work to refresh the list here. new GetDataTask().execute(); } }); mListItems = new LinkedList&String&(); mListItems.addAll(Arrays.asList(mStrings)); ArrayAdapter&String& adapter = new ArrayAdapter&String&(this, android.R.layout.simple_list_item_1, mListItems); setListAdapter(adapter); } private class GetDataTask extends AsyncTask&Void, Void, String[]& { @Override protected String[] doInBackground(Void... params) { // Simulates a background job. try { Thread.sleep(2000); } catch (InterruptedException e) { } return mS } @Override protected void onPostExecute(String[] result) { mListItems.addFirst("Added after refresh..."); // Call onRefreshComplete when the list has been refreshed. ((PullToRefreshListView) getListView()).onRefreshComplete(); super.onPostExecute(result); } } private String[] mStrings = { // "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", // "Abondance", "Ackawi", "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", "Allgauer Emmentaler"}; }
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具新浪微博打开刷新首页那个界面,不能刷新出以前看的内容,如果没有新内容,就直接显示关注别人_百度知道
新浪微博打开刷新首页那个界面,不能刷新出以前看的内容,如果没有新内容,就直接显示关注别人
jpg" target="_blank" title="点击查看大图" class="ikqb_img_alink"><img class="ikqb_img" src="http.baidu.baidu&nbsp://c.hiphotos:///zhidao/pic//zhidao/wh%3D600%2C800/sign=a2ef39d0fcf2b211e47b8d48faba7b0084af5d3572c10dfcfaf.baidu.hiphotos.jpg" esrc="http://c.com/zhidao/wh%3D450%2C600/sign=02a9ae64baaec950a7b0084af5d3572c10<a href="http
提问者采纳
退出帐号重新登录,如果还不行就卸载了重装就行。
提问者评价
太给力了,你的回答完美地解决了我的问题,非常感谢!
其他类似问题
为您推荐:
新浪微博的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁您的举报已经提交成功,我们将尽快处理,谢谢!
大家还关注
(window.slotbydup=window.slotbydup || []).push({
id: '2081942',
container: s,
size: '1000,60',
display: 'inlay-fix'抓狂,新浪微博今晨“刷不新”
原标题:抓狂,新浪微博今晨“刷不新”
□记者 程怡 钱朱建晚报讯 “为什么微博一直无法刷新,是我家的网络坏了,还是新浪微博出现故障了? ”今天上午8:40左右,不少市民致电本报114新闻热线反映。直到上午9点半左右,新浪微博的刷新系统才恢复正常运作。记者致电新浪微博客服人员获悉,确实出现系统故障,技术人员立即对此进行抢修,直到9:28,系统恢复正常。从上午8点半起,本报热线就接到不少市民打来的电话,询问是否家里的网络出现故障,导致新浪微博系统始终无法刷新。而且都显示“系统繁忙”字样。为此,记者也立即打开微博发现,虽然个人主页能够打开,但里面的各种客户端都显示 “加载失败”,而且个人微博更新功能也无法刷新。记者尝试用手机和电脑分别通过3G网络以及无线WIFI进行刷新,不是“系统繁忙”就是“加载失败”。为此,记者立即与新浪微博的客服取得联系。可能是咨询电话太多,新浪个人客服端的始终处于电话繁忙无法打入。记者随即通过企业客服端与新浪客服取得联系,获悉,确实从早上八点半起,新浪微博的系统出现故障,无法实施“刷新”功能。而技术人员在获悉情况后立即对此进行抢修,根据情况应该在上午九点半左右会恢复正常。上午9:28左右,记者再次刷新微博发现,系统已经基本恢复正常,虽然有时还是会显示系统繁忙,但已经能够刷新微博内容了。记者注意到,社交媒体故障后,很多网友都出现焦虑的情绪。事实上,微博、微信一旦出故障,造成的影响已经越来越大。专家点评一故障,“社交媒体依赖症”就发作今天上午,记者采访了上海社会科学院信息研究所信息安全研究中心主任惠志斌,在他看来,如今微博、微信等社交媒体的快速发展,已经让上亿用户特别是都市白领产生了极大的依赖症。一旦 “微博控”、“微信控”发现无法正常使用这些社交媒体,就会出现不同程度的不适应。惠志斌分析,这种高度依赖,和高速发展的社会经济密不可分。随着生活节奏加快,产生大量碎片化的时间。社交媒体碎片化、即时性的特点正好迎合了都市人的生活节奏。而国外一项最新调查表明,中国用户在使用社交媒体上的平均时间达到4小时,正越来越超越以往的“碎片化”时间认识。有些人的使用时间和投入的经历,甚至超越了工作时间。惠志斌认为,这种趋势,不能简单用好或坏来评价。但如果一个人乘车、吃饭、开会、聚会甚至起床后和睡前都在忙着发微博、微信,这种依赖程度已经十分惊人。此外,随着几亿用户的频繁使用,要维护平台稳定性,对微博、微信等社交媒体而言,其压力也是巨大的。特别是,如今很多公司、机构都在借助微博、微信平台发出自己的声音,平台已经成为他们的重要推广平台。据悉,国外一些机构还借助挖掘分析社交媒体中的大数据,已经能对股票指数等商业活动进行分析和预判。此外,社交媒体还是社会情绪的映射,对政府决策等有重要意义。“出故障,还只是个人无法聊天,影响面相对较小。但微博、微信等社交媒体的故障,可能对社会、人群产生影响,造成不安全感和不稳定的情绪,甚至是社会公共安全问题。 ”从这个层面来说,社交媒体的技术故障,可能不亚于某个银行或者通信公司的故障。
用手机随时随地看新闻
独家独到独立
用户名&&密码所有评论仅代表网友意见,凤凰网保持中立 
04/21 07:02
04/21 07:02
04/21 07:02
04/21 06:49
04/21 11:28
03/09 16:46
02/24 09:56
03/09 16:45
03/09 16:45
02/27 16:10
03/13 08:17
03/12 08:43
03/12 07:22
03/12 07:57
03/20 09:48
09/07 09:38
09/07 09:38
09/07 09:39
09/07 09:39
09/07 09:39
04/26 09:49
04/23 08:47
04/23 08:57
04/23 09:14
04/23 09:22
48小时点击排行
财经 · 房产
娱乐 · 时尚
汽车 · 旅游
科技 · 健康

我要回帖

更多关于 新浪首页 的文章

 

随机推荐