Fragment implements OnClickListener

后端 未结 4 832
醉话见心
醉话见心 2020-12-29 06:19

I\'ve got an application that I\'m modernizing. One step of this process is changing to a Fragment based layout (using the Fragments from the support library). I converted m

4条回答
  •  别那么骄傲
    2020-12-29 07:11

    view.setOnLongClickListener(new View.OnLongClickListener() {
      @Override
      public boolean onLongClick(View v) {
        switch (v.getId()) {
          case R.id.imgView1:
            Toast.makeText(getActivity(), "Long pressing", Toast.LENGTH_SHORT).show();
            updateImage();
            break;
          case R.id.imgView2:
            Toast.makeText(getActivity(), "Long pressing", Toast.LENGTH_SHORT).show();
            updateImage();
            break;
          case R.id.imgView3:
            Toast.makeText(getActivity(), "Long pressing", Toast.LENGTH_SHORT).show();
            updateImage();
            break;
          default:
            break;
        }
    

提交回复
热议问题