use of android.view.View.OnClickListener in project coursera-android by aporter.
the class KeyServiceUser method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
final TextView output = (TextView) findViewById(R.id.output);
final Button goButton = (Button) findViewById(R.id.go_button);
goButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
// Call KeyGenerator and get a new ID
if (mIsBound)
output.setText(mKeyGeneratorService.getKey());
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
}
});
}
use of android.view.View.OnClickListener in project coursera-android by aporter.
the class AsyncTaskActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mImageView = (ImageView) findViewById(R.id.imageView);
;
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
final Button button = (Button) findViewById(R.id.loadButton);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
new LoadIconTask().execute(R.drawable.painter);
}
});
final Button otherButton = (Button) findViewById(R.id.otherButton);
otherButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(AsyncTaskActivity.this, "I'm Working", Toast.LENGTH_SHORT).show();
}
});
}
use of android.view.View.OnClickListener in project coursera-android by aporter.
the class ValueAnimatorActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button startButton = (Button) findViewById(R.id.start_animation_button);
startButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startAnimation();
}
});
}
use of android.view.View.OnClickListener in project coursera-android by aporter.
the class SharedPreferenceReadWriteActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SharedPreferences prefs = getPreferences(MODE_PRIVATE);
setContentView(R.layout.main);
// High Score
final TextView highScore = (TextView) findViewById(R.id.high_score_text);
highScore.setText(String.valueOf(prefs.getInt(HIGH_SCORE, 0)));
//Game Score
final TextView gameScore = (TextView) findViewById(R.id.game_score_text);
gameScore.setText(String.valueOf("0"));
// Play Button
final Button playButton = (Button) findViewById(R.id.play_button);
playButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Random r = new Random();
int val = r.nextInt(1000);
gameScore.setText(String.valueOf(val));
// Get Stored High Score
if (val > prefs.getInt(HIGH_SCORE, 0)) {
// Get and edit high score
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(HIGH_SCORE, val);
editor.commit();
highScore.setText(String.valueOf(val));
}
}
});
// Reset Button
final Button resetButton = (Button) findViewById(R.id.reset_button);
resetButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Set high score to 0
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(HIGH_SCORE, 0);
editor.commit();
highScore.setText(String.valueOf("0"));
gameScore.setText(String.valueOf("0"));
}
});
}
use of android.view.View.OnClickListener in project coursera-android by aporter.
the class LoggingServiceClient method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button messageButton = (Button) findViewById(R.id.message_button);
messageButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Create an Intent for starting the LoggingService
Intent startServiceIntent = new Intent(getApplicationContext(), LoggingService.class);
// Put Logging message in intent
startServiceIntent.putExtra(LoggingService.EXTRA_LOG, "Log this message");
// Start the Service
startService(startServiceIntent);
}
});
}
Aggregations