第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Android Studio調(diào)試按鈕按下 - 事件未觸發(fā)

Android Studio調(diào)試按鈕按下 - 事件未觸發(fā)

躍然一笑 2022-10-20 17:06:38
我使用設(shè)計(jì)模式屏幕設(shè)計(jì)創(chuàng)建了這個(gè)屏幕。這個(gè)問(wèn)題基于 XML 的底部,帶有 btnSave 按鈕。在我的 Java 類中,我試圖創(chuàng)建一個(gè)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;@Overrideprotected 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            }        });    }但是,當(dāng)我將應(yīng)用程序 (Shift + F9) 調(diào)試到我連接的設(shè)備 (OnePlus 6T) 時(shí),沒有一個(gè)斷點(diǎn)被命中。此外,當(dāng)我按下按鈕并且文本框?yàn)榭瞻讜r(shí),不會(huì)顯示消息警報(bào)。我做錯(cuò)了什么嗎?我嘗試使用 XMLonClick:屬性,但結(jié)果相同,并且在設(shè)計(jì)模式下設(shè)置了相同的屬性,但同樣沒有任何變化。
查看完整描述

4 回答

?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

你為什么使用這樣的點(diǎn)擊監(jiān)聽器:findViewById(R.id.btnSave).setOnClickListener(null);


改為這樣做:


findViewById(R.id.btnSave).setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

               //put all your textView logic here

            }

        });


查看完整回答
反對(duì) 回復(fù) 2022-10-20
?
白衣非少年

TA貢獻(xiàn)1155條經(jīng)驗(yàn) 獲得超0個(gè)贊

更改此行:


findViewById(R.id.btnSave).setOnClickListener(null);


進(jìn)入


findViewById(R.id.btnSave).setOnClickListener(btnSaveListener);


onCreate并從方法中刪除以下行。


然后創(chuàng)建btnSaveListener如下:


private View.OnClickListener btnSaveListener =new View.OnClickListener() {


   @Override

   public void onClick(View v) {

      // here goes all the code belove the line you change in the method `onCreate`

   }

};


查看完整回答
反對(duì) 回復(fù) 2022-10-20
?
慕蓋茨4494581

TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊

最后,這不是我如何設(shè)置聽眾的問(wèn)題。

將活動(dòng)調(diào)用從我的MainActivity啟動(dòng)類更改為StartActivity意味著OnCreate代碼被正確調(diào)用。



查看完整回答
反對(duì) 回復(fù) 2022-10-20
?
慕容森

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊

你的按鈕點(diǎn)擊監(jiān)聽器實(shí)現(xiàn)是錯(cuò)誤的,試試這樣:


 findViewById(R.id.action_ask).setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {


                // 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

                        }

                    });

                }


                if (txtFolder.getText().length() == 0)

                {

                    // MESSAGE BOX

                    AlertDialog.Builder msg = new AlertDialog.Builder(this);

                    msg.setTitle("Enter Folder");

                    msg.setMessage("Please enter a folder to use.");

                    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

                        }

                    });

                }


                if (txtUsername.getText().length() == 0)

                {

                    // MESSAGE BOX

                    AlertDialog.Builder msg = new AlertDialog.Builder(this);

                    msg.setTitle("Enter Username");

                    msg.setMessage("Please enter your username.");

                    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

                        }

                    });

                }


                if (txtPassword.getText().length() == 0)

                {

                    // MESSAGE BOX

                    AlertDialog.Builder msg = new AlertDialog.Builder(this);

                    msg.setTitle("Enter Server");

                    msg.setMessage("Please enter a your password.");

                    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

                        }

                    });

                }

            }

        });



查看完整回答
反對(duì) 回復(fù) 2022-10-20
  • 4 回答
  • 0 關(guān)注
  • 219 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)