package com.example.hp.exercise10_sharepreference;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Main2Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Intent Myintent = getIntent();
        Setting mysetting = new Setting();
        final String[] ThemeColor = new String[1];

        mysetting = (Setting) Myintent.getParcelableExtra("setting");

        Button btnred = (Button) findViewById(R.id.btnenter);
        Button btngreen = (Button) findViewById(R.id.btngreen);
        Button btnblue = (Button) findViewById(R.id.btnblue);
        TextView mytext = (TextView) findViewById(R.id.textView);
        Button btnlogout = (Button) findViewById(R.id.btnlogout);
        btnlogout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Pref mypref = new Pref(Main2Activity.this);

                Setting mysetting = new Setting();
                mysetting.setUsername("");
                mysetting.setPassword("");
                mypref.setsetting(mysetting);

                Log.d("myintent1", "logout");
                finish();
               // Intent Myintent2 = new Intent(Main2Activity.this, MainActivity.class);
               // startActivity(Myintent2);
                Log.d("========", "myintent2");

            }
        });
        mytext.setText(mysetting.getUsername());
        // final Setting finalMysetting = mysetting;


    }

    public void changeTheme(String theme, Setting mysetting) {
        Pref mypref = new Pref(Main2Activity.this);
        mysetting.setThemecolor(theme);
        mypref.setsetting(mysetting);
    }
}

@@ -292,16 +292,45 @@
 extView;
+%0Aimport android.widget.Toast;
 %0A%0Apublic
@@ -806,141 +806,985 @@
 .btn
-enter);%0A        Button btngreen = (Button) findViewById(R.id.btngreen);%0A        Button btnblue = (Button) findViewById(R.id.btnblue);
+red);%0A        btnred.setOnClickListener(new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A                ThemeColor%5B0%5D=%22RED%22;%0A               // Toast.makeText(Main2Activity.this, %22RED%22, Toast.LENGTH_SHORT).show();%0A            %7D%0A        %7D);%0A%0A        Button btngreen = (Button) findViewById(R.id.btngreen);%0A        btngreen.setOnClickListener(new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A                ThemeColor%5B0%5D=%22GREEN%22;%0A                //Toast.makeText(Main2Activity.this, %22GREEN%22, Toast.LENGTH_SHORT).show();%0A%0A            %7D%0A        %7D);%0A        Button btnblue = (Button) findViewById(R.id.btnblue);%0A        btnblue.setOnClickListener(new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A                ThemeColor%5B0%5D=%22BLUE%22;%0A               // Toast.makeText(Main2Activity.this, %22BLUE%22, Toast.LENGTH_SHORT).show();%0A            %7D%0A        %7D);%0A
 %0A   
@@ -2294,32 +2294,34 @@
 %0A               
+//
  Log.d(%22myintent
@@ -2510,16 +2510,18 @@
         
+//
 Log.d(%22=

SET OnClickListener for Color Buttons