ActivityはFragmentにhandlerでメッセージを伝えます


Activityセクション:
public Handler mHandler;

******************************

Message msg=new Message();
msg.obj=et_agricul_search.getText().toString();//  
msg.what=1;
mHandler.sendMessage(msg);

fragmentセクション:
public android.os.Handler handler=new android.os.Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case 1:
                    strType=msg.obj.toString();
                    firstRefresh();
                    break;
            }
        }
    };

// Activity 
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        AgriculturallSearchActivity mActivity=getParentActivity();
        mActivity= (AgriculturallSearchActivity) activity;
        mActivity.setHandler(handler);
    }

簡単で乱暴である.