Я новичок в Android и работаю над простым проектом, который требует входа и регистрации. Когда я нажимаю ссылки, чтобы ссылаться на другое действие, кнопки не работают.Android Buttons dont work нажмите на ссылку
вот мой код ....
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_login"
android:gravity="center"
android:padding="10dp"
tools:context=".LoginActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:weightSum="1">
<ImageView android:src="@drawable/logo_bg"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginBottom="100dp"
android:layout_gravity="center_horizontal"
android:contentDescription="@string/Zilwacom_Logo" />
<TextView android:id="@+id/login"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginBottom="24dp"
android:text="@string/welcome_to_zilwacom"
android:gravity="center"
android:textSize="24sp"
android:layout_weight="0.14" />
<!-- Email Label -->
<EditText
android:id="@+id/loginemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="@string/Email" />
<!-- Password Label -->
<EditText
android:id="@+id/loginpassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="@string/Password"/>
<Button
android:id="@+id/btnlogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginBottom="24dp"
android:padding="12dp"
android:text="@string/Login"/>
<TextView
android:id="@+id/linksignup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:background="@null"
android:text="@string/btn_link_to_register"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="15dp"
android:clickable="true"/>
</LinearLayout>
</LinearLayout>
и мой код Логин Когда пользователь нажимает кнопку, чтобы подписаться, приложение SHD открыть SIGNUP активность
public class LoginActivity extends AppCompatActivity {
private EditText email;
private EditText password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
//Get reference to buttons and texts
//buttons
Button loginbtn =(Button) findViewById(R.id.btnlogin);
TextView signuplink=(TextView) findViewById(R.id.linksignup);
//Texts
email=(EditText) findViewById(R.id.loginemail);
password=(EditText) findViewById(R.id.loginpassword);
signuplink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(LoginActivity.this, SignupActivity.class);
startActivity(i);
}
});
}
}
Вам также нужно использовать 'setOnClickListener' на вашей кнопке. Это проблема? Вы уже добавили 'setOnClickListener' на кнопку и получили некоторую ошибку? –
Да, я сделал, и у меня такая же ошибка, Я попытался повторить весь проект, но все равно получаю ту же ошибку. Я хочу использовать свое текстовое изображение и сделать его доступным для клика ... (linksignup) – enockdaniels
Что это ошибка? –