Help me I'm trying to develop app for Sudoku Im stuck at this Im just Bsc First yr guy don't know anything
Here My Xml code for my TextView Code
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/change"
android:text="Not Changed"/>
Here is my XML code for Button
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="Test Button"
app:layout_constraintBottom_toTopOf="@+id/btn_sample"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Here is My Java Code
public void btn(View view) {
TextView t=(TextView)findViewById(change);
t.setText("Changed");
}
If I succeed it will Motivate me and my CLG mates I'm noob here sorry for bad English Thanks in Advance
Update : Answer is Solved New code for Button
<Button
android:id="@+id/btn"
android:onClick="btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="Test Button"
app:layout_constraintBottom_toTopOf="@+id/btn_sample"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
New Updated Code for Java
public void btn(View view) {
TextView t=(TextView)findViewById(R.id.change);
t.setText("Changed");
}
Thanks to nilesh-rathod