android 怎么刷新当前的页面 android 怎么刷新当前的页面。评论完成后 怎么刷新当前的页面 ,显示出来。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Invalidate不过你确定要刷新页面么?如果是listview之类的单单刷新他们就好了 //发送按钮 case R.id.news_reply_post: //隐藏输入法 m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); String str = mNewsReplyEditText.getText().toString(); if(str.equals("")){ Toast.makeText(CommentsActivity.this, "不能为空", Toast.LENGTH_SHORT).show(); } else { mNewsReplyEditLayout.post(new PostCommentsThread(mNid, "广州市", str + "", new NewsDetailActivity())); mNewsReplyEditLayout.setVisibility(View.GONE); mNewsReplyImgLayout.setVisibility(View.VISIBLE); loader_ref(); } break; }public void loader_ref() { new Thread() { public void run() { commentsAdapter.notifyDataSetChanged(); //这个刷新不起作用的 //loaddata(); } }.start(); }================================是listview的Invalidate 是怎么用的呢? 你的新评论加到commentsAdapter里面了嘛? //获取新闻的编号 Intent intent = getIntent(); mNid = intent.getIntExtra("nid", 0); mCommentsData = new ArrayList<HashMap<String,Object>>(); Button commentsToNewBtn = (Button) findViewById(R.id.comments_titlebar_news); getComments(mNid); commentsAdapter = new SimpleAdapter(this, mCommentsData , R.layout.comments_list_item_layout , new String[] {"commentator_from", "comment_ptime", "comment_content"} , new int[] { R.id.commentator_from, R.id.comment_ptime, R.id.comment_content}); commentsList = (ListView) findViewById(R.id.comment_list); commentsList.setAdapter(commentsAdapter); // 实例化一个handler Handler handler = new Handler() { //接收到消息后处理 public void handleMessage(Message msg) { switch (msg.what) { case 1: //Log.i("--------------", "0000000000000000"); Intent intent = new Intent(CommentsActivity.this,CommentsActivity.class); intent.putExtra("nid", mNid); startActivity(intent); //commentsAdapter.notifyDataSetChanged(); //commentsList.invalidate(); //刷新界面 break; } super.handleMessage(msg); } };如果重新 跳转那就可以 。 不知道还有更好的方法没有呢 这个在方法说明中写了,Adapter的notifyDataSetChanged()方法的调用一般是在UI主线程才会起作用的吧,同理的invalidate()方法也是一样,需要借用Handler尚可在UI主线程起作用。为保险起见,我一般在项目的做法是组合一起用,绝对有效 :)commentsList.setAdapter(commentsAdapter);//重新为listview设置更新后的commentsAdaptercommentsAdapter.notifyDataSetChanged(); //更新显示 TabHost每个选项卡的字体颜色怎么修改? 如何实现图片压缩 在做一个简单的Android电子词典是,遇到英文单词音标不能正常显示,有谁帮忙看看? android ndk相关 Andriod收集的开发资料大放送 一个c函数输出是void*类型的东西,请问在jni怎么处理? 手机定时发送数据 间断问题 困扰了1个月 ExpandableListView中二级列表序号怎么获得 虚拟机UI主界面竖屏,但内容横屏,求高大大解答!!! extends自BroadcastReceiver的类怎么传递参数 我觉得应用越轻越好,用Clouda开发很省力气哇哈哈 计算机科学与技术专业毕设如何选题?
不过你确定要刷新页面么?
如果是listview之类的单单刷新他们就好了
case R.id.news_reply_post:
//隐藏输入法
m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
String str = mNewsReplyEditText.getText().toString();
if(str.equals("")){
Toast.makeText(CommentsActivity.this, "不能为空",
Toast.LENGTH_SHORT).show();
}
else {
mNewsReplyEditLayout.post(new PostCommentsThread(mNid, "广州市",
str + "",
new NewsDetailActivity()));
mNewsReplyEditLayout.setVisibility(View.GONE);
mNewsReplyImgLayout.setVisibility(View.VISIBLE);
loader_ref();
}
break;
}
public void loader_ref()
{
new Thread()
{
public void run()
{
commentsAdapter.notifyDataSetChanged(); //这个刷新不起作用的
//loaddata();
}
}.start();
}
================================
是listview的
Invalidate 是怎么用的呢?
//获取新闻的编号
Intent intent = getIntent();
mNid = intent.getIntExtra("nid", 0);
mCommentsData = new ArrayList<HashMap<String,Object>>();
Button commentsToNewBtn = (Button) findViewById(R.id.comments_titlebar_news);
getComments(mNid);
commentsAdapter = new SimpleAdapter(this, mCommentsData
, R.layout.comments_list_item_layout
, new String[] {"commentator_from", "comment_ptime", "comment_content"}
, new int[] { R.id.commentator_from, R.id.comment_ptime, R.id.comment_content});
commentsList = (ListView) findViewById(R.id.comment_list);
commentsList.setAdapter(commentsAdapter);
{
//接收到消息后处理 public void handleMessage(Message msg) {
switch (msg.what) { case 1:
//Log.i("--------------", "0000000000000000");
Intent intent = new Intent(CommentsActivity.this,CommentsActivity.class);
intent.putExtra("nid", mNid);
startActivity(intent);
//commentsAdapter.notifyDataSetChanged();
//commentsList.invalidate(); //刷新界面
break; } super.handleMessage(msg); } };如果重新 跳转那就可以 。 不知道还有更好的方法没有呢
commentsAdapter.notifyDataSetChanged(); //更新显示