Skip to main content

Android Studio: Cara ganti warna text saat tombol diklik

Berikut adalah tutorial pembuatan aplikasi menggunakan android studio cata ganti warna text pada saat tombol diklik.
Berikut adalah design activity_main.xml nya.

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"    android:background="@drawable/s44"    tools:context="com.daniyusuf.gantiwarna.MainActivity">

    <TextView        android:id="@+id/txt_hello"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello World!"        android:textAlignment="center"        android:textColor="@android:color/background_light"        android:textSize="90sp"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toTopOf="parent" />

    <Button        android:id="@+id/btn_merah"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_alignParentBottom="true"        android:layout_alignParentLeft="true"        android:layout_alignParentStart="true"        android:background="@color/colorAccent"        android:onClick="gantiMerah"        android:text="Warna Merah" />

    <Button        android:id="@+id/button"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_above="@+id/btn_merah"        android:layout_alignParentLeft="true"        android:layout_alignParentStart="true"        android:background="@color/colorPrimary"        android:onClick="gantiBiru"        android:text="Warna Biru" />

</RelativeLayout>


Comments

Popular posts from this blog

Program PHP sederhana untuk menghitung simulasi kredit

Membuat Form <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #333333; } --> </style></head> <?php $harga=$_GET['harga']; $dp=$harga*0.2; ?> <body> <H2>FORM SIMULASI KREDIT </H2> <br /> <form id="form1" name="form1" method="post" action="simulasi_proses1.php"> <table width="580" border="0" cellspacing="2" cellpadding="2"> <tr> <td>Harga Kendaraan </td> ...

Contoh Kerangka Pemikiran

Berikut adalah contoh kerangka pemikiran yang diambil dari saran dan masukan Dosen Pengajar Bapak Romi Satria Wahoho.

Android Studio Webview dengan Custom Error Page

Pada tutorial kali ini akan dijelaskan cara membuat webview yang akan menampilkan custom error page apabila tidak ada koneksi internet. Buka file MainActivity.java Kemudian rubah isinya sebagai berikut: package com.danie.indihome; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class Main2Activity extends AppCompatActivity { WebView wb ; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout. activity_main2 ); wb =(WebView)findViewById(R.id. wb ); WebSettings ws= wb .getSettings(); ws.setJavaScriptEnabled( true ); //wb.loadUrl("http://ubharajaya.com/masteradmin/admin@web/"); wb .loadUrl( "http://ubharajaya.com/mobile/index.php" ); wb .setWebViewClient(...