/*
========================================================================================
Filename: 05_TextColorChange.txt
Program 05: Create an app that changes text color when a button is clicked.
Files Included: MainActivity.java
========================================================================================

WHAT ALL TO DO / SETUP INSTRUCTIONS:
----------------------------------------------------------------------------------------
1. UI Components to Add (in res/layout/activity_main.xml):
   Add 2 TextView:
     - tvColorText: Heading 'Color Change'
     - tvColorName: Label showing the current color name (e.g. 'Red', 'Green', 'Blue')
   Add 1 Button:
     - Text: 'Change', onClick: 'changeTextColor'

2. Layout Configuration:
   - LinearLayout (vertical, gravity='center', padding 20dp)

3. Menu Configuration:
   - None required.

4. Themes Configuration (res/values/themes.xml):
   - Default theme. No changes needed.

5. AndroidManifest.xml:
   <activity android:name=".MainActivity" android:exported="true" />

6. Additional Files & Resources Required:
   - None.
========================================================================================
*/

// ======================================================================================
// File: MainActivity.java
// ======================================================================================
package com.example.textcolorchange;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    TextView tvColorText,tvColorName;
    int[] colors= {
        Color.RED,Color.BLUE,Color.GREEN,Color.YELLOW,Color.MAGENTA
    };
    String[] names= {
        "RED","BLUE","GREEN","YELLOW","MAGENTA"
    };
    int i=0;
    @Override
    protected void onCreate(Bundle b) {
        super.onCreate(b);
        setContentView(R.layout.activity_main);
        tvColorText=findViewById(R.id.tvColorText);
        tvColorName=findViewById(R.id.tvColorName);
    }

    public void changeTextColor(View v) {
        tvColorText.setTextColor(colors[i]);
        tvColorName.setText(names[i]);
        i=(i+1)%colors.length;
    }
}
