首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >每秒钟更新一次“可停止列表的孩子”视图中的剩余时间

每秒钟更新一次“可停止列表的孩子”视图中的剩余时间
EN

Stack Overflow用户
提问于 2015-03-18 14:26:31
回答 1查看 176关注 0票数 0

**代码每秒钟查看一次剩余时间,但没有执行任何操作,..i无法折叠组、展开另一个组或单击需要帮助的子..Please :( **)

in Profile片段

代码语言:javascript
运行
复制
expListView.setOnGroupExpandListener(new OnGroupExpandListener() {    
     @Override
     public void onGroupExpand(final int groupPosition) {
        // notify=true;
        SharedPreferences prefs = rootview.getContext().getSharedPreferences("QuranerUser", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putInt("center_pos", groupPosition);
        editor.putString("centerid", result.get(0).get(0).get(0).get(groupPosition));
        editor.commit();

        LayoutInflater infalInflater = (LayoutInflater) rootview.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = infalInflater.inflate(R.layout.list_item, null);
        final TextView newtime=(TextView)view.findViewById(R.id.rtime);

        LayoutInflater infalInflater2 = (LayoutInflater)  rootview.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater2.inflate(R.layout.list_group, null);


        m_Runnable = new Runnable() {
            public void run() {                    
                for(int i=0;i<re_result.get(groupPosition).size();i++){                          
                      r_t=Long.parseLong(re_result.get(groupPosition).get(i));
                      r_t=r_t-1;
                      if(r_t>0){
                        re_result.get(groupPosition).set(i, Long.toString(r_t));
                        listAdapter.notifyDataSetChanged();                                 
                        ExpandableListAdapter.formate_Remainig(re_result.get(groupPosition).get(i)));
                        //  resetDataCell(v);

                        }
                        // update every second                    
                }

                m_Handler.postDelayed(m_Runnable, 1000);
            }}; 

         Toast.makeText(getActivity(),
                 listDataHeader.get(groupPosition) + " Expanded",
                 Toast.LENGTH_SHORT).show();
     }
    });


 // Listview Group collasped listener
 expListView.setOnGroupCollapseListener(new OnGroupCollapseListener() {

     @Override
     public void onGroupCollapse(int groupPosition) {
         notify=false;
           Toast.makeText(getActivity(),
                 listDataHeader.get(groupPosition) + " Collapsed",
                 Toast.LENGTH_SHORT).show();

     }
 });

In ExpandableListAdapter:

代码语言:javascript
运行
复制
final TextView newtime=(TextView)view.findViewById(R.id.rtime);
final Thread testthread = new Thread() {
    @Override
    public void run() {
        android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);       
        try {
            while(true) {
                sleep(1000);
                MyProfileFragment.m_Handler.post(MyProfileFragment.m_Runnable);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
};

testthread.start();

newtime.setText(formate_Remainig(Rem.get(groupPosition).get(childPosition)));
time_schedule=Start_time(Long.parseLong(EN.get(groupPosition).get(childPosition)),Long.parseLong(ST.get(groupPosition).get(childPosition)),Integer.parseInt(offset.get(groupPosition).get(childPosition)));

String check = check_time(Long.parseLong(EN.get(groupPosition).get(childPosition)), Long.parseLong(ST.get(groupPosition).get(childPosition)),Days.get(groupPosition).get(childPosition));

if(check.equalsIgnoreCase("time")){
    newtime.setVisibility(TextView.VISIBLE);
    newtime.setText(formate_Remainig(Rem.get(groupPosition).get(childPosition)));}
EN

回答 1

Stack Overflow用户

发布于 2015-03-20 18:57:30

使用AsyncTask怎么样?

我是在listview中实现的,每一行都有进度条。

代码语言:javascript
运行
复制
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
download(view);}
}
);

void download{
  TextView tvTitle = (TextView) view.findViewById(R.id.tvTitle);
//use async task to update it
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29124708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档