我怎样才能进行对话?我怎样才能解决这个问题?

时间:2016-06-12 13:52:17

标签: android

首先,抱歉我的英语。我正在尝试使用2个按钮和textview创建一个对话框。当我单击一个按钮时,程序跳过第一部分并跳转到第二部分。 我怎样才能解决这个问题?我的目标是进行如下对话:

  • +嗨,你好吗?
  • - 良好
  • -Bad
  • (点击为坏)

  • +为什么你感觉不好?

  • - 因为他咬我
  • - 因为我受伤了

    感谢您的帮助:| !

    Dim SQL as String = "Select * from employee"
    Dim cmd as MySqlCommand = new MySqlCommad(SQL, connection)
    Dim reader as MysqlDataReader = cmd.executeReader()
    Dim empId, empName, empAddress as String
    
    'before adding new row in datagridview add this code
    DataGridView1.Rows.clear();
    with reader.Read
        empId = reader("empId")
        empName = reader("name")
        empAddress = reader("address")
    

2 个答案:

答案 0 :(得分:0)

您可以在Activity中创建使用AlertDialog的Dialog Fragments,然后使用Intent调用下一个对话框。以下是Android开发者网站关于对话框和其他意图的链接:

创建对话框片段: https://developer.android.com/guide/topics/ui/dialogs.html

意图: https://developer.android.com/guide/components/intents-filters.html

答案 1 :(得分:-1)

您需要使用this

根据您的要求,您的代码应如下所示:

    MaterialDialog dialog = new MaterialDialog.Builder(this)
        .content("Hi, how are you?")
        .positiveText("Good")
        .negativeText("Bad")
        .show();

    // Handle Good click
    dialog.onPositive(new MaterialDialog.SingleButtonCallback() {
        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
             new MaterialDialog.Builder(this)   
            .content("You clicked Good")
            .positiveText("OK")              
            .show();
        }
    })

    // Handle Bad click
    dialog.onPositive(new MaterialDialog.SingleButtonCallback() {
        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
             new MaterialDialog.Builder(this)   
            .content("Why feeling bad?")
            .positiveText("Because he bit me")
            .negativeText("Because I am wounded")
            .show();   
        }
    })

希望有所帮助!!

相关问题