android.support.v7.app.AppCompatDelegate.findViewById()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(199)

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

AppCompatDelegate.findViewById介绍

暂无

代码示例

代码示例来源:origin: Justson/AgentWeb

private void showChooserInternal(WebView view, String url, final String[] ways, final Handler.Callback callback) {
  LogUtils.i(TAG, "url:" + url + "  ways:" + ways[0]);
  RecyclerView mRecyclerView;
  if (mBottomSheetDialog == null) {
    mBottomSheetDialog = new BottomSheetDialog(mActivity);
    mRecyclerView = new RecyclerView(mActivity);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
    mRecyclerView.setId(RECYCLERVIEW_ID);
    mBottomSheetDialog.setContentView(mRecyclerView);
  }
  mRecyclerView = (RecyclerView) mBottomSheetDialog.getDelegate().findViewById(RECYCLERVIEW_ID);
  mRecyclerView.setAdapter(getAdapter(ways, callback));
  mBottomSheetDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
    @Override
    public void onCancel(DialogInterface dialog) {
      if (callback != null) {
        callback.handleMessage(Message.obtain(null, -1));
      }
    }
  });
  mBottomSheetDialog.show();
}

代码示例来源:origin: pili-engineering/PLDroidShortVideo

private void setBehaviorCallback() {
  View view = getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet);
  final BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(view);
  bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
    @Override
    public void onStateChanged(@NonNull View bottomSheet, int newState) {
      if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
      }
    }
    @Override
    public void onSlide(@NonNull View bottomSheet, float slideOffset) {
    }
  });
}

代码示例来源:origin: nekocode/JarFilterPlugin

@SuppressWarnings("TypeParameterUnusedInFormals")
@Override
public <T extends View> T findViewById(@IdRes int id) {
  return getDelegate().findViewById(id);
}

代码示例来源:origin: PandaQAQ/MvpDemo

private void setBehaviorCallback() {
  View view = mBottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet);
  assert view != null;
  final BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(view);
  bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
    @Override
    public void onStateChanged(@NonNull View bottomSheet, int newState) {
      if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        mBottomSheetDialog.dismiss();
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
      }
    }
    @Override
    public void onSlide(@NonNull View bottomSheet, float slideOffset) {
      // 对 BottomSheetDialog 进行上下滑动时会调用此方法
    }
  });
}

代码示例来源:origin: pinguo-zhouwei/MaterialDesignSamples

/**
 * share Dialog
 */
private void showShareDialog(){
  if(mBottomSheetDialog == null){
    mBottomSheetDialog = new BottomSheetDialog(this);
    View view = LayoutInflater.from(this).inflate(R.layout.bottom_sheet_share_dialog,null);
    mBottomSheetDialog.setContentView(view);
    mBottomSheetDialog.setCancelable(true);
    mBottomSheetDialog.setCanceledOnTouchOutside(true);
    // 解决下滑隐藏dialog 后,再次调用show 方法显示时,不能弹出Dialog
    View view1 = mBottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet);
    final BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(view1);
    bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
      @Override
      public void onStateChanged(@NonNull View bottomSheet, int newState) {
        if (newState == BottomSheetBehavior.STATE_HIDDEN) {
          Log.i("BottomSheet","onStateChanged");
          mBottomSheetDialog.dismiss();
          bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        }
      }
      @Override
      public void onSlide(@NonNull View bottomSheet, float slideOffset) {
      }
    });
  }else{
    mBottomSheetDialog.show();
  }
}

相关文章