亲爱的,这是我的代码,textview文字无法更改?.....
AlertDialog.Builder builder=new AlertDialog.Builder(User.this);
LayoutInflater inflater = (User.this).getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the
// dialog layout
rname=(TextView)inflater.inflate(R.layout.fooditemview, null).findViewById(R.id.tv_frname);
fname=(TextView)inflater.inflate(R.layout.fooditemview, null).findViewById(R.id.tv_fname);
ftype=(TextView)inflater.inflate(R.layout.fooditemview, null).findViewById(R.id.tv_ftype);
fdetails=(TextView)inflater.inflate(R.layout.fooditemview, null).findViewById(R.id.tv_fdetails);
remail=(TextView)inflater.inflate(R.layout.fooditemview, null).findViewById(R.id.tv_email);
rname.setText(Srname);
ftype.setText(Sftype);
fdetails.setText(Sfdetails);
remail.setText(Ssremail);
fname.setText(Sfname);
builder.setTitle("Food Details");
// builder.setIcon(R.drawable.ic_launcher);
builder.setCancelable(true);
builder.setView(inflater.inflate(R.layout.fooditemview, null))
// Add action buttons
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
builder.create();
builder.show();
}
logcat中的错误是
02-24 14:19:58.846: E/AndroidRuntime(11065): FATAL EXCEPTION: main
02-24 14:19:58.846: E/AndroidRuntime(11065): Process:com.example.foodadviser, PID: 11065
02-24 14:19:58.846: E/AndroidRuntime(11065): java.lang.NullPointerException
02-24 14:19:58.846: E/AndroidRuntime(11065): at com.example.foodadviser.User.FoodDetailsDialog(User.java:457)
02-24 14:19:58.846: E/AndroidRuntime(11065): at com.example.foodadviser.User.access$2(User.java:440)
02-24 14:19:58.846: E/AndroidRuntime(11065): at com.example.foodadviser.User$1.onItemSelected(User.java:87)
02-24 14:19:58.846: E/AndroidRuntime(11065): at android.widget.AdapterView.fireOnSelected(AdapterView.java:893)
02-24 14:19:58.846: E/AndroidRuntime(11065): at android.widget.AdapterView.access$200(AdapterView.java:48)
02-24 14:19:58.846: E/AndroidRuntime(11065): at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:861)
02-24 14:19:58.846: E/AndroidRuntime(11065): at android.os.Handler.handleCallback(Handler.java:808)
02-24 14:19:58.846: E/AndroidRuntime(11065): at android.os.Handler.dispatchMessage(Handler.java:103)
02-24 14:19:58.846: E/AndroidRuntime(11065): at android.os.Looper.loop(Looper.java:193)
02-24 14:19:58.846: E/AndroidRuntime(11065): at android.app.ActivityThread.main(ActivityThread.java:5292)
02-24 14:19:58.846: E/AndroidRuntime(11065): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 14:19:58.846: E/AndroidRuntime(11065): at java.lang.reflect.Method.invoke(Method.java:515)
02-24 14:19:58.846: E/AndroidRuntime(11065): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
02-24 14:19:58.846: E/AndroidRuntime(11065): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
02-24 14:19:58.846: E/AndroidRuntime(11065): at dalvik.system.NativeStart.main(Native Method)
02-24 14:19:59.043: D/dalvikvm(11065): threadid=17: interp stack at 0x60b74000
我试过这个请帮帮我。如何解决这个问题。 这甚至可能不会破坏所有内容而只是创建一个自定义视图(我非常反对尝试解决这个新的Android编程...)