Question: Keep in mind the Model-View-Controller principles to build your app.You should have a model object, a view object, and a controller object in your assignment.
Keep in mind the Model-View-Controller principles to build your app.You should have a model object, a view object, and a controller object in your assignment.
Design a program for an app on android studios that adds one each time the TAP button is clicked.
Modify this program to create one button to Tap Up (+) and one button to Tap Down (-) the counter value.You will likely need to make changes to the layout, the strings file, the Counter class, and MainActivity.
Layout is the phone screen and the app design
Counter- package com.example.tapandcount; public class Counter { private int mCount; public Counter(){ mCount = 0; } public void addCount(){ mCount++; } public Integer getCount(){ return mCount; } }
Main Activity-
package com.example.tapandcount; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity { private Counter count; private TextView countView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); count = new Counter(); countView = (TextView)findViewById(R.id.textView); } public void countTap(View view){ count.addCount(); countView.setText(count.getCount().toString()); } }
String-
TapAndCount 0 TAP
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
