package com.jsd.demo;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;/**
*
* @author jiangshide
**/
public classJsdMainDialog extends Activity {privateContext mContext;privateButton mSub;privateTextView mResultValue;public static Handler handler = newHandler();
@Overridepublic voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getViewById();
}public voidgetViewById(){
mContext= this;
mSub= (Button) this.findViewById(R.id.sub);
mResultValue= (TextView) this.findViewById(R.id.resultValue);
mResultValue.setText("没有通过Handler处理");
mSub.setOnClickListener(listener);
}private OnClickListener listener = newOnClickListener() {
@Overridepublic voidonClick(View v) {switch(v.getId()) {caseR.id.sub:
final String flag= "rqbackvalue";
DialogCustomer dc= newDialogCustomer(mContext,flag);
dc.show();
handler= newHandler(){public voidhandleMessage(Message msg) {
String resultFlag= msg.getData().getString("flags");if(resultFlag.equalsIgnoreCase(flag)){
mResultValue.setText("这是通过Handler处理过后来显示数据的");
mResultValue.setTextColor(Color.CYAN);
mResultValue.setTextSize(30);
}
};
};break;default:break;
}
}
};
}