java - 制作使用 java 类 .contains 的吐司不起作用
问题描述
我正在尝试制作 android 应用程序,显示链接是否包含 https 并且不起作用(在编辑代码后没有 toast 出现)我认为使用 '. contains()'... 我可以在这些方面寻求帮助吗?这些是用 java 编写的,并在 android 7.0 环境中进行了测试。
package com.example.messengerandroid7;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.app.AlertDialog;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Button button;
TextView resultLabel;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.button);
resultLabel = findViewById(R.id.resultLabel);
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
class indexOf {
class contains {
public void main(String[] args) {
EditText url = findViewById(R.id.url);
String urlname = url.getText().toString();
Log.v(urlname, "test");
if (urlname.contains("https")) {
Toast.makeText(MainActivity.this, "xxxxxx", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MainActivity.this, "ㅇㅇㅇㅇㅇ", Toast.LENGTH_LONG).show();
}
}
}
}
}
});
}
}
解决方案
推荐阅读
- javascript - 无法合并选择
- swift - Swift 中的 C# 或 Java 泛型接口等价于什么?
- android - 如何从firebase获取url图像并将其保存在字符串中?
- kotlin - 多平台环境下的 Kotlin 反射/动态函数调用
- haskell - 使用 Haskell 的 Req 库和 Scalpel 将文件保存到客户端
- amazon-web-services - 如何使用 Swagger 在 API 网关上全局设置 API 密钥安全性
- java - Java anagram 工作代码,帮助理解代码的概念
- angular - Angular如何在QueryList中找到哪个元素
被点击 - python - 是否有在 Python 中动态添加 Microsoft Word 脚注的解决方法?
- php - 如何将数据从下拉列表发布到 PHP 中的过滤表?