我使用设计模式屏幕设计创建了这个屏幕。

这个问题基于 XML 的底部,带有 btnSave 按钮。
在我的 Java 类中,我试图创建一个onClickListener类似的
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class ftpDetails extends AppCompatActivity{
private TextView txtServer;
private TextView txtFolder;
private TextView txtUsername;
private TextView txtPassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ftp_details);
setTitle(R.string.ftpTitle);
txtServer = (TextView) findViewById(R.id.txtServer);
txtFolder = (TextView) findViewById(R.id.txtFolder);
txtUsername = (TextView) findViewById(R.id.txtUsername);
txtPassword = (TextView) findViewById(R.id.txtPassword);
findViewById(R.id.btnSave).setOnClickListener(null);
// Check that all text boxes have a value in them
if (txtServer.getText().length() == 0)
{
// MESSAGE BOX
AlertDialog.Builder msg = new AlertDialog.Builder(this);
msg.setTitle("Enter Server");
msg.setMessage("Please enter a server address.");
msg.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Leave this blank, this will mean nothing happens, the msg just disappears
}
});
}
但是,当我将应用程序 (Shift + F9) 调试到我连接的设备 (OnePlus 6T) 时,没有一个断点被命中。此外,当我按下按钮并且文本框为空白时,不会显示消息警报。
我做错了什么吗?我尝试使用 XMLonClick:属性,但结果相同,并且在设计模式下设置了相同的属性,但同样没有任何变化。
跃然一笑
GCT1015
白衣非少年
慕盖茨4494581
慕容森
随时随地看视频慕课网APP
相关分类