Search in sources :

Example 71 with OnClickListener

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());
            }
        }
    });
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) RemoteException(android.os.RemoteException) TextView(android.widget.TextView) View(android.view.View)

Example 72 with OnClickListener

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();
        }
    });
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View)

Example 73 with OnClickListener

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();
        }
    });
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View)

Example 74 with OnClickListener

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"));
        }
    });
}
Also used : Random(java.util.Random) SharedPreferences(android.content.SharedPreferences) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 75 with OnClickListener

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);
        }
    });
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) View(android.view.View)

Aggregations

OnClickListener (android.view.View.OnClickListener)794 View (android.view.View)792 TextView (android.widget.TextView)492 Button (android.widget.Button)265 ImageView (android.widget.ImageView)256 Intent (android.content.Intent)183 ListView (android.widget.ListView)112 AdapterView (android.widget.AdapterView)91 ScrollView (android.widget.ScrollView)52 LinearLayout (android.widget.LinearLayout)49 Bundle (android.os.Bundle)43 LayoutInflater (android.view.LayoutInflater)35 ViewGroup (android.view.ViewGroup)30 ArrayList (java.util.ArrayList)30 BindView (butterknife.BindView)29 KeyEvent (android.view.KeyEvent)28 EditText (android.widget.EditText)28 DialogInterface (android.content.DialogInterface)27 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)25 FragmentManager (android.support.v4.app.FragmentManager)23