我有DialogFragment
以下方法:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
builder.setView(inflater.inflate(R.layout.buddy_challenge, null));
this.title = (TextView)getActivity().findViewById(R.id.challenge_title);
this.challenge = (Button)getActivity().findViewById(R.id.challenge_button);
this.at = (AutoCompleteTextView)getActivity().findViewById(R.id.chall_ex);
ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("action", "getAllEx"));
new ServerCallEx().execute(params);
return builder.create();
}
自定义布局正确膨胀,但如果我尝试更改 TextView 或尝试将适配器附加到 AutoCompleteTextView 我得到一个空指针异常并且无法弄清楚为什么(不知道为什么getActivity.findViewByID()
不工作)。帮助!