簡體   English   中英

子進程完成后更新列表

[英]Updating a list after a child process has finished

該應用程序的主要活動是顯示列表。 用戶單擊列表上的某些內容,這將打開一個編輯屏幕。 完成后,關閉編輯屏幕-我希望使用編輯屏幕上發生的任何內容更新原始列表。 我將數據保存到文件中,然后可以再次讀取它以更新列表。 但是我不知道在哪里插入重新讀取的代碼。

在ListActivity中-什么叫列表重新獲得焦點的方法?

這是我的主要List活動代碼:

創建視圖:

@Override
       public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Inflate our UI from its XML layout description.
    setContentView(R.layout.my_activity);

   list=new Data_List(this);  // my data reading class
   list.read_data();           // reads from a file

  load_dynamic_list();

}

加載數據:

private void load_dynamic_list(){
             ladapter=new         
list_adapter(this,android.R.layout.simple_list_item_1,list);  // the type is actually  ignored                                                                                  // getview function in list_adapter handles everything
          setListAdapter(ladapter);
         this.getListView().invalidate();

}

選擇了一些東西:

protected void onListItemClick (ListView l, View v, int position, long id){
  int a;
   intent = new Intent(this,Editing.class);

        intent.putExtra("New_entry",0);
        intent.putExtra("Entry",position);


        //start the second Activity
        this.startActivity(intent);


 }

在“編輯”功能中,我這樣結束:

    @Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    if(v.getId() == R.id.button_save){
        do_save();  // saves to a file

  //  I want something like: caller.getListView().invalidate();

         finish();
                    }
    if(v.getId() == R.id.button_cancel){
        finish();
                    }
}

編輯完成后,我可以重寫或調用哪種方法? 那時我想先load_dynamic_list() read_data() ,然后再load_dynamic_list()

 @Override
 protected void onResume() {
      super.onResume();

     list=new Data_List(this);
     list.read_data();
           load_dynamic_list();    // becuase whatever was edited needs to be reread. 

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM