-3
I’m new in programming for android, I know java and c#, I want to press the button and change the label text only managed to appear on Toast
package gabriel.meaperte;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import static android.widget.TextView.*;
public class MainActivity extends AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void exibirmensagem(View view){
Toast.makeText(MainActivity.this, "Você apertou o botão", Toast.LENGTH_LONG).show();
}
}
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aperte o botão"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.174"
app:layout_constraintHorizontal_bias="0.502"
android:id="@+id/textView" />
<Button
android:id="@+id/button"
android:layout_width="159dp"
android:layout_height="85dp"
android:text="Botão"
android:onClick="exibirmensagem"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.55"
app:layout_constraintHorizontal_bias="0.502" />
What error is occurring?
– Marcelo de Andrade
Report the error, so that a response compatible with your problem can be posted....
– JcSaint