在单击确认方法中放置什么,以便特定视图可以轻松执行特定作业

时间:2015-03-28 13:26:45

标签: android

在单击确认方法中放入什么,以便特定视图可以轻松执行特定作业?我的布局中有图像视图,我想要做的就是一次点击每个imageview做一个特定的工作。任何人都可以告诉我一个方法必须这样做。

`public boolean onSingleTapConfirmed(MotionEvent e){                   Toast.makeText(Creaacount_5.this,"单击",Toast.LENGTH_SHORT).show();                   EditText b =(EditText)findViewById(R.id.editText1);                      在b.append(" *&#34);

             switch(id){
                 case 0:
                     id=R.id.imageView1;
                    Toast.makeText(Creaacount_5.this, "play", Toast.LENGTH_SHORT).show();
                     SharedPreferences s1=getSharedPreferences(MyPreferences,MODE_PRIVATE);
                       SharedPreferences.Editor editor1=s1.edit();
                       editor1.putInt("play", R.drawable.playing);
                       editor1.commit();

                       break;

               case 1:
                           id=R.id.imageView3;
                     Toast.makeText(Creaacount_5.this,"think",Toast.LENGTH_SHORT).show();

                      SharedPreferences s2=getSharedPreferences(MyPreferences,MODE_PRIVATE);
                       SharedPreferences.Editor editor2=s2.edit();
                       editor2.putInt("thinking", R.drawable.think);
                       editor2.commit();

                     break;

                case 2:
                    id=R.id.imageView4;
                    SharedPreferences s3=getSharedPreferences(MyPreferences,MODE_PRIVATE);
                       SharedPreferences.Editor editor3=s3.edit();
                       editor3.putInt("eating", R.drawable.eat);

                       editor3.commit();
                  break;

                }
             return true;

          }
`

0 个答案:

没有答案