// 標題web
RelativeLayout view = (RelativeLayout) getLayoutInflater().inflate(ide
R.layout.webviewheader, null);spa
Button back = (Button) view.findViewById(R.id.btn_back);指針
back.setOnClickListener(new OnClickListener() {webview
@Overrideget
public void onClick(View v) {sed
onBackPressed();List
}layout
});view
view.setLayoutParams(new LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT));
int w = RelativeLayout.MeasureSpec.makeMeasureSpec(0,
MeasureSpec.UNSPECIFIED);
int h = RelativeLayout.MeasureSpec.makeMeasureSpec(0,
MeasureSpec.UNSPECIFIED);
view.measure(w, h);
int x = view.getMeasuredHeight();
layout.addView(view);
若是不先設置
view.setLayoutParams(new LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT));
這句代碼調用view.measure(w, h);回報空指針