create a project and enter the skeleton example Modify the program so that the b
ID: 3878852 • Letter: C
Question
create a project and enter the skeleton example
Modify the program so that the button label has a different message each time it's pressed (at least 10 different messages).
Please give the code for the project.
D Beginning Android 2 N × >g Dindex-of.co.uk/Android/Beginning%20Android%202%20-%20Murphy%20-%20Apress%20(2010).pdf ::: Apps Blackboard @ NCAT VMware Horizon D Bi material eBook D Beginning Android 2Biomechanics Sens EN The Role of pressure Beginning Android 2 - Murphy - Apress (2010).pdf 36/ 417 NOTE: If you downloaded the source files from the Apress web site, you can just use the Skeleton/Now project directly, rather than entering the code. Open Now.java in your editor and paste in the following code: package con.conmonsware.android.skeleton; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import ava.util.Date public class Now extends Activity implements View.OnClickListener ( Button btn 0verride public void onCreate(Bundle icicle) t super.onCreate(icicle); btn-new Button(this); btn.setOnClickListener(this); updateTime); setContentView (btn); public void onClick(View vie) I updateTime); private void updateTime) btn.setText (new Date) toString)); Let's examine this piece by piece Dissectina the Activit 9:10 PM Type here to search w 1/24/2018Explanation / Answer
here is your code : --------------------->>>>>>>>>>>>>>>>
package com.commonsware.android.skelton;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.util.Date;
public class Now extends Activity implements View.OnClickListener{
Button btn;
String[] texts;
int count = 0;
@Override
public void onCreate(Bundle icicle){
super.onCreate(icicle);
texts = new String[10];
texts[0] = new String("now2");
texts[1] = new String("now3");
texts[2] = new String("now4");
texts[3] = new String("now5");
texts[4] = new String("now6");
texts[5] = new String("now7");
texts[6] = new String("now8");
texts[7] = new String("now9");
texts[8] = new String("now1");
texts[9] = new String("now10");
btn = new Button(this);
btn.setText(texts[count]);
count++;
updateTime();
setContentView(btn);
}
public void onClick(View view){
updateTime();
}
private void updateTime(){
btn.setText(texts[count]+(new Date().toString()));
count++;
count = count % 10;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.