android.widget.ImageView.setOnFocusChangeListener()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中android.widget.ImageView.setOnFocusChangeListener()方法的一些代码示例,展示了ImageView.setOnFocusChangeListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setOnFocusChangeListener()方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:setOnFocusChangeListener

ImageView.setOnFocusChangeListener介绍

暂无

代码示例

代码示例来源:origin: z-android/ZLayer

public static void setImageSelector(Context context,
                  final ImageView imageView, int drawableNormal, int drawableFocused) {
  InputStream streamNormal = context.getResources().openRawResource(
      drawableNormal);
  final Bitmap bitmapNormal = BitmapFactory.decodeStream(streamNormal);
  InputStream streamFocused = context.getResources().openRawResource(
      drawableFocused);
  final Bitmap bitmapFocused = BitmapFactory.decodeStream(streamFocused);
  imageView.setImageBitmap(bitmapNormal);
  imageView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean hasFocus) {
      if (hasFocus) {
        imageView.setImageBitmap(bitmapFocused);
      } else {
        imageView.setImageBitmap(bitmapNormal);
      }
    }
  });
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

@Override
protected void onFinishInflate() {
  super.onFinishInflate();
  mAllAppsHandle = (ImageView) findViewById(R.id.all_apps_handle);
  mAllAppsHandle.setImageDrawable(getCaretDrawable());
  mAllAppsHandle.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
  mAllAppsHandle.setOnClickListener(mLauncher);
  mAllAppsHandle.setOnLongClickListener(mLauncher);
  mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
  mLauncher.setAllAppsButton(mAllAppsHandle);
}

代码示例来源:origin: enricocid/LaunchEnr

@Override
protected void onFinishInflate() {
  super.onFinishInflate();
  mAllAppsHandle = (ImageView) findViewById(R.id.all_apps_handle);
  mAllAppsHandle.setImageDrawable(getCaretDrawable());
  mAllAppsHandle.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
  mAllAppsHandle.setOnClickListener(mLauncher);
  mAllAppsHandle.setOnLongClickListener(mLauncher);
  mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
  mLauncher.setAllAppsButton(mAllAppsHandle);
}

代码示例来源:origin: klinker24/launcher3

@Override
protected void onFinishInflate() {
  super.onFinishInflate();
  mAllAppsHandle = (ImageView) findViewById(R.id.all_apps_handle);
  mAllAppsHandle.setImageDrawable(getCaretDrawable());
  mAllAppsHandle.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
  mAllAppsHandle.setOnClickListener(mLauncher);
  mAllAppsHandle.setOnLongClickListener(mLauncher);
  mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
  mLauncher.setAllAppsButton(mAllAppsHandle);
}

代码示例来源:origin: abrenoch/hyperion-android-grabber

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mMediaProjectionManager = (MediaProjectionManager)
                  getSystemService(Context.MEDIA_PROJECTION_SERVICE);
  ImageView iv = findViewById(R.id.power_toggle);
  iv.setOnClickListener(this);
  iv.setOnFocusChangeListener(this);
  iv.setFocusable(true);
  iv.requestFocus();
  setImageViews(mRecorderRunning, false);
  LocalBroadcastManager.getInstance(this).registerReceiver(
      mMessageReceiver, new IntentFilter(HyperionScreenService.BROADCAST_FILTER));
  checkForInstance();
}

代码示例来源:origin: abrenoch/hyperion-android-grabber

private void initActivity() {
  // assume the recorder is not running until we are notified otherwise
  mRecorderRunning = false;
  setContentView(R.layout.activity_main);
  AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  mMediaProjectionManager = (MediaProjectionManager)
                  getSystemService(Context.MEDIA_PROJECTION_SERVICE);
  ImageView iv = findViewById(R.id.power_toggle);
  iv.setOnClickListener(this);
  iv.setOnFocusChangeListener(this);
  iv.setFocusable(true);
  iv.requestFocus();
  ImageButton ib = findViewById(R.id.settingsButton);
  ib.setOnClickListener(this);
  ib.setOnFocusChangeListener(this);
  ib.setFocusable(true);
  setImageViews(mRecorderRunning, false);
  LocalBroadcastManager.getInstance(this).registerReceiver(
      mMessageReceiver, new IntentFilter(BROADCAST_FILTER));
  // request an update on the running status
  checkForInstance();
}

相关文章

ImageView类方法