i invoke findViewById method like this:
view view = LayoutInflater.from(this).inflate(R.layout.xxx,null); Customview myView = view.findviewbyid(R.id.xy); .... setcontentView(view);
but it keeps return null . after searchs, i found that i shoud call findviewbyid() before setcontentview method. you can also do like this:
You call this method: inflater.inflate(R.layout.picture_method_option, null, false); And you ignore the result. The last parameter, false, indicates to not add the content of the XML layout to the layout root (which you set to null anyway.) You need to do something like this: View v = inflater.inflate(R.layout.picture_method_option, null, false); addView(v); Or: inflater.inflate(R.layout.picture_method_option, this, true);