From 518c9c3e367bed2c84d1f3a01044d94e98c1bd54 Mon Sep 17 00:00:00 2001 From: tashsmit Date: Tue, 19 May 2015 20:42:02 -0400 Subject: [PATCH 1/4] what i have so far 8:42 --- src/main/java/nyc/c4q/InitialActivity.java | 23 ++++++++ src/main/res/layout/activity_initial.xml | 66 +++++++++++++++++++++- 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/src/main/java/nyc/c4q/InitialActivity.java b/src/main/java/nyc/c4q/InitialActivity.java index 2213b83..25cadce 100644 --- a/src/main/java/nyc/c4q/InitialActivity.java +++ b/src/main/java/nyc/c4q/InitialActivity.java @@ -9,7 +9,10 @@ import android.widget.Button; import android.widget.TextView; +import org.w3c.dom.Text; + public class InitialActivity extends Activity { + int numCounter = 0; public int counter = 0; public SharedPreferences preferences = null; @@ -19,6 +22,25 @@ public void loadState(){ Log.d(TAG, "loadState()"); counter = preferences.getInt("counter", 0); Log.d(TAG, "loadState(): counter=="+counter); + + + Button plus = (Button) findViewById(R.id.buttonPlus); + plus.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + numCounter++; + TextView counter = (TextView) findViewById(R.id.tvCounter); + counter.setText(Integer.toString(numCounter)); + } + }); + + Button minus = (Button) findViewById(R.id.buttonMinus); + plus.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + numCounter--; + TextView counter = (TextView) findViewById(R.id.tvCounter); + counter.setText(Integer.toString(numCounter)); + } + }); } public void saveState(){ @@ -35,4 +57,5 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_initial); preferences = getPreferences(Context.MODE_PRIVATE); } + } diff --git a/src/main/res/layout/activity_initial.xml b/src/main/res/layout/activity_initial.xml index 49e22b0..7571f6b 100644 --- a/src/main/res/layout/activity_initial.xml +++ b/src/main/res/layout/activity_initial.xml @@ -3,11 +3,70 @@ + android:id="@+id/activity_initial" + android:orientation="horizontal"> + + + + + +