1

Can someone tell me what's wrong with this code? Eclipse doesn't show any errors, but nothing happens when the spinner is clicked.

Code:

Spinner startTime = ( Spinner ) findViewById ( R.id.project_start_time);

    startTime.setOnTouchListener(new OnTouchListener(){

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Toast.makeText ( NewTaskActivity.this, "test", Toast.LENGTH_SHORT );
            return false;
        }

    });

XML:

<Spinner
    android:id="@+id/project_start_time"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />
abc32112
  • 2,457
  • 9
  • 37
  • 53

3 Answers3

4

You just forget to call show() method on your Toast messege.

Toast.makeText ( NewTaskActivity.this, "test", Toast.LENGTH_SHORT ).show();
heri.wijoyo
  • 276
  • 1
  • 6
1

add .show() at the end of Toast.makeTest()

vinay Maneti
  • 1,447
  • 1
  • 23
  • 31
1

You forget to call .show() method at end of the Toast.

Spinner startTime = ( Spinner ) findViewById ( R.id.project_start_time);

startTime.setOnTouchListener(new OnTouchListener(){

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        Toast.makeText ( NewTaskActivity.this, "test", Toast.LENGTH_SHORT ).show();
        return false;
    }

});
Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
Sakthivel Appavu
  • 565
  • 5
  • 24