package com.sf.manager.eventbus2;


import android.app.ListFragment;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;


import de.greenrobot.event.EventBus;

public class ItemListFragment extends ListFragment
{

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // Register 订阅事件
        EventBus.getDefault().register(this);
    }

    @Override
    public void onDestroy()
    {
        super.onDestroy();
        // Unregister 取消订阅
        EventBus.getDefault().unregister(this);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState)
    {
        super.onViewCreated(view, savedInstanceState);
        // 开启线程加载列表
        new Thread()
        {
            public void run()
            {
                try
                {
                    Thread.sleep(2000); // 模拟延时
                    // 发布事件，在后台线程发的事件。 在下面绑定适配器处相应
                    EventBus.getDefault().post(new Event.ItemListEvent(Item.ITEMS));
                } catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
            };
        }.start();
    }

    public void onEventMainThread(Event.ItemListEvent event)
    {
        Log.e("eve", "new Event.ItemListEvent(Item.ITEMS)");
        setListAdapter(new ArrayAdapter<Item>(getActivity(),
                android.R.layout.simple_list_item_activated_1,
                android.R.id.text1, event.getItems()));
    }

    @Override
    public void onListItemClick(ListView listView, View view, int position,
                                long id)
    {
        super.onListItemClick(listView, view, position, id);
        EventBus.getDefault().post(getListView().getItemAtPosition(position));
    }

}
@@ -247,16 +247,17 @@
 ntBus;%0A%0A
+%0A
 public c
@@ -302,10 +302,11 @@
 ment
+ %7B
 %0A
-%7B
 %0A%0A  
@@ -360,36 +360,32 @@
 edInstanceState)
-%0A   
  %7B%0A        super
@@ -407,32 +407,33 @@
 InstanceState);%0A
+%0A
         // Regis
@@ -535,20 +535,16 @@
 estroy()
-%0A   
  %7B%0A     
@@ -728,20 +728,16 @@
 ceState)
-%0A   
  %7B%0A     
@@ -798,474 +798,104 @@
     
-// %E5%BC%80%E5%90%AF%E7%BA%BF%E7%A8%8B%E5%8A%A0%E8%BD%BD%E5%88%97%E8%A1%A8%0A        new Thread()%0A        %7B%0A            public void run()%0A            %7B%0A                try%0A                %7B%0A                    Thread.sleep(2000); // %E6%A8%A1%E6%8B%9F%E5%BB%B6%E6%97%B6%0A                    // %E5%8F%91%E5%B8%83%E4%BA%8B%E4%BB%B6%EF%BC%8C%E5%9C%A8%E5%90%8E%E5%8F%B0%E7%BA%BF%E7%A8%8B%E5%8F%91%E7%9A%84%E4%BA%8B%E4%BB%B6%E3%80%82 %E5%9C%A8%E4%B8%8B%E9%9D%A2%E7%BB%91%E5%AE%9A%E9%80%82%E9%85%8D%E5%99%A8%E5%A4%84%E7%9B%B8%E5%BA%94%0A                    EventBus.getDefault().post(new Event.ItemListEvent(Item.ITEMS));%0A                %7D catch (InterruptedException e)%0A                %7B%0A                    e.printStackTrace();%0A                %7D%0A            %7D;%0A        %7D.start(
+Event.ItemListEvent event = new Event.ItemListEvent(7);%0A        EventBus.getDefault().post(event
 );%0A 
@@ -960,20 +960,16 @@
 t event)
-%0A   
  %7B%0A     
@@ -989,43 +989,27 @@
 %22, %22
-new Event.ItemListEvent(Item.ITEMS)
+  do in this class 
 %22);%0A
@@ -1048,20 +1048,22 @@
 Adapter%3C
-Item
+String
 %3E(getAct
@@ -1070,32 +1070,16 @@
 ivity(),
-%0A               
  android
@@ -1117,32 +1117,16 @@
 vated_1,
-%0A               
  android
@@ -1258,40 +1258,8 @@
 ion,
-%0A                               
  lon
@@ -1263,20 +1263,16 @@
 long id)
-%0A   
  %7B%0A     
@@ -1414,8 +1414,9 @@
     %7D%0A%0A%7D
+%0A

Update ItemListFragment.java