有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java按钮单击不使用材质设计?

我用材质设计库创建了一个按钮 ,我的设计是正确的,代码是正确的,但它不响应点击,我能为响应的按钮做些什么 点击,我想修改一些代码 到按钮功能工作

main活动

public class MainActivity extends AppCompatActivity {

                @Override
                protected void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.activity_main);

                    ButtonRectangle buttonSelectColor = (ButtonRectangle) findViewById(R.id.button4);

                    buttonSelectColor.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View arg0) {
                          Log.i("trace","don");

                        }
                    });
                }
                // End ;
            }

XML

<?xml version="1.0" encoding="utf-8"?>
                <RelativeLayout
                    xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
                    xmlns:tools="http://schemas.安卓.com/tools"
                    安卓:layout_width="match_parent"
                    安卓:layout_height="match_parent"
                    安卓:background="#ffffff"
                    tools:context=".MainActivity">


                    <com.gc.materialdesign.views.ButtonRectangle
                        安卓:id="@+id/button4"
                        安卓:layout_width="wrap_content"
                        安卓:layout_height="wrap_content"
                        安卓:background="#1E88E5"
                        安卓:text="Button6787" />

                </RelativeLayout>

格拉德尔。依赖关系

apply plugin: 'com.安卓.application'

                安卓 {
                    compileSdkVersion 29
                    buildToolsVersion "29.0.1"
                    defaultConfig {
                        applicationId "com.ahmedco.testcode2"
                        minSdkVersion 15
                        targetSdkVersion 29
                        versionCode 1
                        versionName "1.0"
                        testInstrumentationRunner "安卓x.test.runner.AndroidJUnitRunner"
                    }
                    buildTypes {
                        release {
                            minifyEnabled false
                            proguardFiles getDefaultProguardFile('proguard-安卓-optimize.txt'), 'proguard-rules.pro'
                        }
                    }
                }

                dependencies {
                    implementation fileTree(dir: 'libs', include: ['*.jar'])
                    implementation '安卓x.appcompat:appcompat:1.1.0'
                    implementation '安卓x.constraintlayout:constraintlayout:1.1.3'
                    testImplementation 'junit:junit:4.12'
                    安卓TestImplementation '安卓x.test:runner:1.2.0'
                    安卓TestImplementation '安卓x.test.espresso:espresso-core:3.2.0'
                    implementation 'com.github.navasmdc:MaterialDesign:1.5@aar'
                }

共 (0) 个答案