Android 单击按钮时登录

Android 单击按钮时登录,android,Android,我认为这个问题很容易解决,但有一点我想不出来 这是一个xml文件,有一些widjet,还有一个注释按钮,我想检查用户何时单击按钮,如果他有帐户,如果没有,我想带他在活动中唱歌, 我知道我应该查一下身份证什么的 对不起,这个愚蠢的问题我会很感激的 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/andro

我认为这个问题很容易解决,但有一点我想不出来 这是一个xml文件,有一些widjet,还有一个注释按钮,我想检查用户何时单击按钮,如果他有帐户,如果没有,我想带他在活动中唱歌, 我知道我应该查一下身份证什么的 对不起,这个愚蠢的问题我会很感激的

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="life.insomnia.inception.movie_Detailes">



        <ImageView
            android:id="@+id/poster"
            android:layout_width="400dp"
            android:layout_height="400dp"
            android:layout_weight="1"
            app:srcCompat="@drawable/split" />

        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="TextView"
            android:layout_alignBottom="@+id/poster"
            android:layout_alignParentStart="true"
            android:height="60dp"
            android:textAlignment="center"
            android:textSize="20sp"
            android:padding="15dp"
            android:textStyle="bold"
            android:textColor="#fff"/>
        <TextView
            android:id="@+id/tag_line"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/poster"
            android:layout_margin="20dp"
            android:textStyle="italic"
            android:textSize="20sp"
            android:text="mdfxvcmvcbnjxmk,x.,cmvbvncmx,;x,cmvncm,;zlx,cmvncmx,zlxkcmvnbvncmx,jzlfjfksdhmjkhfdsdhfkjjslknscnfgskjdpodjakdksjflkfuiweroihjszfdlkfhsoifhsdkgushfjdfkgh"
            />
        <EditText
            android:id="@+id/commenttxt"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="comment here"
            android:layout_below="@+id/tag_line"
            android:layout_margin="15dp"
            />
        <Button
            android:id="@+id/commentbtn"
            android:layout_width="140dp"
            android:layout_height="45dp"
            android:layout_below="@+id/commenttxt"
            android:layout_centerHorizontal="true"/>
</RelativeLayout>

向按钮添加ID:

android:id="@+id/someId"
然后在代码中:

Button b = (Button) findViewById(R.id.someId);
b.setOnClickListener(this);//Make sure the class implements onClickListener
然后在
onClick(视图v)


很抱歉,我无法理解您的问题您的xml在这一点上是不相关的。你需要解释什么不起作用,并张贴一个你实际在做什么的例子。
switch(v.getId()){
    case R.id.someId:
        //login here
    break;
}