0

这将引发空指针异常并使应用程序崩溃。想不通为什么。这可能是因为一些时髦的线程业务。我在想也许处理程序可能会解决它。如果有人有任何想法,我会在此期间尝试一下。谢谢

以下是我得到的错误:

06-04 15:42:34.644: W/dalvikvm(6535): threadid=1: thread exiting with uncaught exception (group=0x40dca438)

传播错误的代码:

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();

builder.setView(inflater.inflate(R.layout.my_layout, null));

Log.i(TAG, "Getting TextView and appending");

((TextView) findViewById(R.id.tvName)).append("appended string");

builder.create().show();
4

1 回答 1

0
LayoutInflater inflater = getActivity().getLayoutInflater();

View view = inflater.inflate(R.layout.my_layout, null);

builder.setView(view);

Log.i(TAG, "Getting TextView and appending");

((TextView) view.findViewById(R.id.tvName)).append("appended string");

builder.create().show();

如果R.id.tvName属于R.layout.my_layout你必须使用膨胀视图来检索它

于 2013-06-08T17:43:11.833 回答