diff --git a/src/main/java/nyc/c4q/InitialActivity.java b/src/main/java/nyc/c4q/InitialActivity.java index 2213b83..126aebe 100644 --- a/src/main/java/nyc/c4q/InitialActivity.java +++ b/src/main/java/nyc/c4q/InitialActivity.java @@ -9,11 +9,20 @@ import android.widget.Button; import android.widget.TextView; -public class InitialActivity extends Activity { +import org.w3c.dom.Text; - public int counter = 0; +import java.util.ArrayList; + +public class InitialActivity extends Activity implements View.OnClickListener { + + public static int counter = 0; public SharedPreferences preferences = null; public final static String TAG = "C4QTAG"; + TextView tvCounter; + Button buttonPlus; + Button buttonMinus; + + public void loadState(){ Log.d(TAG, "loadState()"); @@ -31,8 +40,66 @@ public void saveState(){ @Override protected void onCreate(Bundle savedInstanceState) { + Log.d(TAG, "onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_initial); preferences = getPreferences(Context.MODE_PRIVATE); - } + + tvCounter = (TextView) findViewById(R.id.tvCounter); + buttonPlus = (Button) findViewById(R.id.buttonPlus); + buttonMinus = (Button) findViewById(R.id.buttonMinus); + Button buttonTileActivity = (Button) findViewById(R.id.buttonTileActivity); + Button buttonEmpty = (Button) findViewById(R.id.buttonEmpty); + loadState(); + + // if (savedInstanceState != null) { + // int mCurrentCounter = savedInstanceState.getInt(String.valueOf(counter)); + // } + } + + @Override + protected void onStart() { + super.onStart(); + saveState(); } + + @Override + protected void onResume() { + super.onResume(); + tvCounter.getText(); + } + + + public void onClick (View v) { + + Log.d(TAG, "onClick()"); + if(v.getId()==R.id.buttonPlus){ + counter += 1; + Log.d(TAG, "onClick().buttonPlus, counter="+counter); + tvCounter.setText(String.valueOf(counter)); + saveState(); + } + if (v.getId()==R.id.buttonMinus) { + counter -= 1; + Log.d(TAG, "onClick().buttonMinus, counter="+counter); + tvCounter.setText(String.valueOf(counter)); + saveState(); + } + } + @Override + protected void onSaveInstanceState(Bundle state) { +// state.get(String.valueOf(counter)); + + + super.onSaveInstanceState(state); +// int mCurrentCounter = getInt(counter); + state.putInt("mCurrentCounter", counter); + Log.d("InitialActivity", "onSaveInstanceState"); + + } + + @Override + protected void onStop() { + super.onStop(); + } + } diff --git a/src/main/java/nyc/c4q/SubFunClass.java b/src/main/java/nyc/c4q/SubFunClass.java index ef94dce..aa5669e 100644 --- a/src/main/java/nyc/c4q/SubFunClass.java +++ b/src/main/java/nyc/c4q/SubFunClass.java @@ -3,7 +3,12 @@ /** * Created by amyquispe on 5/19/15. */ -public class SubFunClass { - public SubFunClass(){ +public class SubFunClass extends SuperFunClass { + public SubFunClass (){ + SubFunClass funObject = new SubFunClass(); + } + + public SubFunClass(String someName) { + super(someName); } } diff --git a/src/main/res/layout/activity_initial.xml b/src/main/res/layout/activity_initial.xml index 49e22b0..1c75dc8 100644 --- a/src/main/res/layout/activity_initial.xml +++ b/src/main/res/layout/activity_initial.xml @@ -8,11 +8,61 @@ android:layout_height="match_parent" tools:context="nyc.c4q.InitialActivity" android:id="@+id/activity_initial"> - - + android:layout_height="0dp" + android:layout_weight="2"> + +