gpt4 book ai didi

java - 我的 If 语句强制关闭

转载 作者:行者123 更新时间:2023-12-02 07:56:11 26 4
gpt4 key购买 nike

    Button s2;
AutoCompleteTextView tran;
//Spinner lang;
EditText trans;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.translate);



s2= (Button) findViewById(R.id.button1);
tran= (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
trans = (EditText) findViewById(R.id.editText1);
s2.setOnClickListener(new OnClickListener(){

public void onClick(View dap) {
String input;
String output= null;
input = tran.getText().toString();


if ("Love".equals(input)){

trans.setText("Italian: Amore"+"\n Spanish: Amor"+"\n Japanese: ai / koi"+"\n Mandarin: ai");

}


else
{trans.setText(null);}

我已经阅读了很多有关 if 语句的内容,并且我使用了这个 if ("Love".equals(input)) 代码。每次我单击按钮(s2)时,我都会强制关闭。我的 if 语句有什么问题吗?

这些是出现在我的 logcat 中的行。

03-08 05:50:40.952: D/Vold(29): Volume sdcard state changing 0 (No-Media) -> 1 (Idle-Unmounted)
03-08 05:50:40.992: W/Vold(29): No UMS switch available
03-08 05:50:41.072: D/qemud(38): fdhandler_accept_event: accepting on fd 10
03-08 05:50:41.072: D/qemud(38): created client 0xe078 listening on fd 8
03-08 05:50:41.092: D/qemud(38): fdhandler_event: disconnect on fd 8
03-08 05:50:41.222: D/qemud(38): fdhandler_accept_event: accepting on fd 10
03-08 05:50:41.222: D/qemud(38): created client 0xf028 listening on fd 8
03-08 05:50:41.232: D/qemud(38): client_fd_receive: attempting registration for service 'gsm'
03-08 05:50:41.232: D/qemud(38): client_fd_receive: -> received channel id 1
03-08 05:50:41.242: D/qemud(38): client_registration: registration succeeded for client 1
03-08 05:50:41.443: D/qemud(38): fdhandler_accept_event: accepting on fd 10
03-08 05:50:41.443: D/qemud(38): created client 0x10fd8 listening on fd 11
03-08 05:50:41.472: D/qemud(38): client_fd_receive: attempting registration for service 'boot-properties'
03-08 05:50:41.472: D/qemud(38): client_fd_receive: -> received channel id 2
03-08 05:50:41.482: D/qemud(38): client_registration: registration succeeded for client 2
03-08 05:50:41.482: I/qemu-props(54): connected to 'boot-properties' qemud service.
03-08 05:50:41.492: I/qemu-props(54): received: dalvik.vm.heapsize=24m
03-08 05:50:41.522: I/qemu-props(54): received: qemu.sf.lcd_density=240
03-08 05:50:41.542: I/qemu-props(54): received: qemu.hw.mainkeys=1
03-08 05:50:41.562: I/qemu-props(54): received: qemu.sf.fake_camera=back
03-08 05:50:41.602: I/qemu-props(54): received:
03-08 05:50:41.602: I/qemu-props(54): invalid format, ignored.
03-08 05:50:44.592: D/AndroidRuntime(33): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-08 05:50:44.612: D/AndroidRuntime(33): CheckJNI is ON
03-08 05:50:46.853: I/(34): ServiceManager: 0xacd0
03-08 05:50:46.853: D/AudioHardwareInterface(34): setMode(NORMAL)
03-08 05:50:46.913: I/CameraService(34): CameraService started: pid=34
03-08 05:50:46.992: I/AudioFlinger(34): AudioFlinger's thread 0xb3b8 ready to run
03-08 05:50:47.254: D/AndroidRuntime(33): --- registering native functions ---
03-08 05:50:49.533: I/SamplingProfilerIntegration(33): Profiler is disabled.
03-08 05:50:49.783: I/Zygote(33): Preloading classes...
03-08 05:50:49.793: E/Zygote(33): setreuid() failed. errno: 2
03-08 05:50:49.843: D/dalvikvm(33): GC_EXPLICIT freed 821 objects / 47496 bytes in 41ms

03-08 05:51:40.743: E/BatteryService(68): usbOnlinePath not found
03-08 05:51:40.743: E/BatteryService(68): batteryVoltagePath not found
03-08 05:51:40.753: E/BatteryService(68): batteryTemperaturePath not found
03-08 05:51:40.823: I/sysproc(68): Entered system_init()
03-08 05:51:40.823: I/sysproc(68): ServiceManager: 0x11d650
03-08 05:51:40.856: I/SurfaceFlinger(68): SurfaceFlinger is starting
03-08 05:51:40.863: I/SurfaceFlinger(68): SurfaceFlinger's main thread ready to run. Initializing graphics H/W...
03-08 05:51:40.903: E/SurfaceFlinger(68): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
03-08 05:51:41.003: I/gralloc(68): using (fd=25)

最佳答案

使用 trans.setText("") 更改 else,而不是 trans.setText(null);

关于java - 我的 If 语句强制关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9613217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com