下面列出了android.view.ViewGroup#FOCUS_BLOCK_DESCENDANTS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public int getDescendantFocusability() {
if (workspaceInModalState()) {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
return super.getDescendantFocusability();
}
private void setKeyboardEnabled(final boolean enable) {
mKeyboardEnabled = enable;
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (enable && mMainView.getDescendantFocusability() == ViewGroup.FOCUS_BLOCK_DESCENDANTS) {
mMainView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
showSnackbar("Unblocking keyboard...");
//inputMethodManager.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(), 0);
} else if (!enable) {
mMainView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
mWebView.getRootView().requestFocus();
showSnackbar("Blocking keyboard...");
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
mSharedPrefs.edit().putBoolean("keyboardEnabled", enable).apply();
}
@Override
public int getDescendantFocusability() {
if (workspaceInModalState()) {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
return super.getDescendantFocusability();
}
/**
* Disable focus on anything under this view in the hierarchy if we are not visible.
*/
@Override
public int getDescendantFocusability() {
if (getVisibility() != View.VISIBLE) {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
return super.getDescendantFocusability();
}
@Override
public int getDescendantFocusability() {
if (isSmall()) {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
return super.getDescendantFocusability();
}
/**
* Disable focus on anything under this view in the hierarchy if we are not visible.
*/
@Override
public int getDescendantFocusability() {
if (getVisibility() != View.VISIBLE) {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
return super.getDescendantFocusability();
}
public void onDataListChange() {
removeAllViews();
int len = mBlockListAdapter.getCount();
int w = mBlockListAdapter.getBlockWidth();
int h = mBlockListAdapter.getBlockHeight();
int columnNum = mBlockListAdapter.getCloumnNum();
int horizontalSpacing = mBlockListAdapter.getHorizontalSpacing();
int verticalSpacing = mBlockListAdapter.getVerticalSpacing();
boolean blockDescendant = getDescendantFocusability() == ViewGroup.FOCUS_BLOCK_DESCENDANTS;
for (int i = 0; i < len; i++) {
RelativeLayout.LayoutParams lyp = new RelativeLayout.LayoutParams(w, h);
int row = i / columnNum;
int clo = i % columnNum;
int left = 0;
int top = 0;
if (clo > 0) {
left = (horizontalSpacing + w) * clo;
}
if (row > 0) {
top = (verticalSpacing + h) * row;
}
lyp.setMargins(left, top, 0, 0);
View view = mBlockListAdapter.getView(mLayoutInflater, i);
if (!blockDescendant) {
view.setOnClickListener(mOnClickListener);
}
view.setTag(INDEX_TAG, i);
addView(view, lyp);
}
requestLayout();
}
@Override
public int getDescendantFocusability() {
return mChildrenFocused ? ViewGroup.FOCUS_BEFORE_DESCENDANTS
: ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
@Override public int getDescendantFocusability() {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
@Override public int getDescendantFocusability() {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
@Override
public int getDescendantFocusability() {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
@Override
public int getDescendantFocusability() {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
@Override
public int getDescendantFocusability() {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
@Override
public int getDescendantFocusability ()
{
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}
@Override
public int getDescendantFocusability() {
return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
}