/** Update selected item metadata. */ private void updateSelectedItemMetadata() { View oldSelectedChild = mSelectedChild; View child = mSelectedChild = getChildAt(mSelectedPosition - mFirstPosition); if (child == null) { return; } child.setSelected(true); child.setFocusable(true); if (hasFocus()) { child.requestFocus(); } // We unfocus the old child down here so the above hasFocus check // returns true if (oldSelectedChild != null) { // Make sure its drawable state doesn't contain 'selected' oldSelectedChild.setSelected(false); // Make sure it is not focusable anymore, since otherwise arrow keys // can make this one be focused oldSelectedChild.setFocusable(false); } }
@Test public void testFocusable() { assertFalse(view.isFocusable()); view.setFocusable(true); assertTrue(view.isFocusable()); view.setFocusable(false); assertFalse(view.isFocusable()); }
protected void showPopupWindow( View parentView, int viewWidth, int viewHeight, List<String> goodsColumnGroups) { View view = getLayoutInflater().inflate(R.layout.clasifyfragment, null); view.setFocusable(true); // 这个很重要color="#7a7a7a" view.setFocusableInTouchMode(true); expandableListView = (ListView) view.findViewById(R.id.expandableListView); expandadapter = new Expandadapter( this, goodsColumnGroups, mHandler, parentView.getId() == R.id.tab_all_layout ? StoreConstant.ALL_TYPE : StoreConstant.NEAR_TYPE); expandableListView.setAdapter(expandadapter); mPopupWindow = new PopupWindow(view, viewWidth, viewHeight, true); mPopupWindow.setFocusable(true); mPopupWindow.setBackgroundDrawable(getResources().getDrawable(android.R.color.transparent)); if (null != parentView) { int[] location = new int[2]; parentView.getLocationOnScreen(location); mPopupWindow.showAtLocation( parentView, Gravity.NO_GRAVITY, location[0], location[1] + parentView.getHeight()); mPopupWindow.update(); } // findGoodsColumn(); }
public void setContent(View v) { if (mContent != null) this.removeView(mContent); mContent = v; // mContent.setClickable(true); mContent.setFocusable(true); addView(mContent); }
public static void openMenu(int type, final Activity context, final View layout, final int id) { Animation anim = null; switch (type) { case RIGHT_LEFT: anim = AnimationUtils.loadAnimation(context, R.anim.right_to_left_menu_show); break; case UP_DOWN: anim = AnimationUtils.loadAnimation(context, R.anim.up_to_down_menu_show); break; } if (layout != null) { final View left = layout.findViewById(id); layout.setVisibility(View.VISIBLE); left.setVisibility(View.INVISIBLE); layout.startAnimation(anim); layout.setClickable(true); layout.setFocusable(true); setEnable(false, context); anim.setAnimationListener( new AnimationListener() { @Override public void onAnimationStart(Animation arg0) {} @Override public void onAnimationRepeat(Animation arg0) {} @Override public void onAnimationEnd(Animation arg0) { left.setVisibility(View.VISIBLE); setEnable(true, context); } }); } }
private void initPaintView() { creator = new PaintPadViewCreator((BaseActivity) getActivity(), container_ll); View v = creator.getView(); v.setFocusable(true); v.setFocusableInTouchMode(true); }
private void addTab(final int position, View tab) { tab.setFocusable(true); tab.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); // XXX INDSAT TIL DR RADIO: “Nulstil” visning, når der tappes på kanalikon i toppen, så // man kommer tilbage til NU-visning (belejligt hvis man har scrollet op el. ned i epg // liste) // if (delegatePageListener != null && delegatePageListener instanceof Kanaler_frag) { // ((Kanaler_frag) delegatePageListener).klikPåFane(position); // } // Grimt hack, men desværre umuligt at gøre på en anden måde if (Kanal_frag.senesteSynligeFragment != null) { Kanal_frag.senesteSynligeFragment.rulBlødtTilAktuelUdsendelse(); } // XXX INDSAT TIL DR RADIO s**t } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView( tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
@Test public void shouldNotBeFocusableByDefault() throws Exception { assertFalse(view.isFocusable()); view.setFocusable(true); assertTrue(view.isFocusable()); }
/** * Set the draggable view portion. Use to null, to allow the whole panel to be draggable * * @param dragView A view that will be used to drag the panel. */ public void setDragView(View dragView) { if (mDragView != null) { mDragView.setOnClickListener(null); } mDragView = dragView; if (mDragView != null) { mDragView.setClickable(true); mDragView.setFocusable(false); mDragView.setFocusableInTouchMode(false); mDragView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (!isEnabled() || !isTouchEnabled()) return; if (mSlideState != PanelState.EXPANDED && mSlideState != PanelState.ANCHORED) { if (mAnchorPoint < 1.0f) { setPanelState(PanelState.ANCHORED); } else { setPanelState(PanelState.EXPANDED); } } else { setPanelState(PanelState.COLLAPSED); } } }); ; } }
public FilterLinePw(Context context, CheckBox outCbx, String[] items) { super(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); View contentview = LayoutInflater.from(context).inflate(R.layout.filter_line_popupwindow, null); setContentView(contentview); setFocusable(true); setOutsideTouchable(true); this.outCbx = outCbx; contentview.setOnKeyListener( new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { dismiss(); return true; } return false; } }); contentview.setFocusable(true); // 这个很重要 contentview.setFocusableInTouchMode(true); contentview.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); init(context, contentview, items); }
private void initTabs() { mContainer.removeAllViews(); mTabs.clear(); if (mAdapter == null) return; for (int i = 0; i < 3; i++) { final int index = i; View tab = mAdapter.getView(i); mContainer.addView(tab); tab.setFocusable(true); mTabs.add(tab); if (i != list.size()) { mContainer.addView(getSeparator()); } if (index == 0) { executeTask(list, index); selectTab(index); } tab.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { executeTask(list, index); selectTab(index); } }); } }
public void addActionItem(ActionItem action) { String title = action.getTitle(); Drawable icon = action.getIcon(); View container = (View) inflater.inflate(R.layout.action_item, null); ImageView img = (ImageView) container.findViewById(R.id.iv_icon); TextView text = (TextView) container.findViewById(R.id.tv_title); if (icon != null) img.setImageDrawable(icon); else img.setVisibility(View.GONE); if (title != null) text.setText(title); else text.setVisibility(View.GONE); final int pos = mChildPos; container.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (mListener != null) mListener.onItemClick(pos); dismiss(); } }); container.setFocusable(true); container.setClickable(true); mTrack.addView(container, mChildPos + 1); mChildPos++; }
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final ListView listView = getListView(); final View loaderView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_loader, null); loaderView.setEnabled(false); loaderView.setClickable(false); loaderView.setFocusable(false); loaderView.setFocusableInTouchMode(false); addOnScrollListener( new OnScrollListener() { @Override public void onScrollStateChanged(final AbsListView view, final int scrollState) {} @Override public void onScroll( final AbsListView view, final int firstVisibleItem, final int visibleItemCount, final int totalItemCount) { final int lastInScreen = firstVisibleItem + visibleItemCount; if ((lastInScreen == totalItemCount) && listView.getAdapter() != null) { onLoadMoreItems(); } } }); listView.addFooterView(loaderView); }
public AndroidInput( Application activity, Context context, Object view, AndroidApplicationConfiguration config) { // we hook into View, for LWPs we call onTouch below directly from // within the AndroidLivewallpaperEngine#onTouchEvent() method. if (view instanceof View) { View v = (View) view; v.setOnKeyListener(this); v.setOnTouchListener(this); v.setFocusable(true); v.setFocusableInTouchMode(true); v.requestFocus(); } this.config = config; this.onscreenKeyboard = new AndroidOnscreenKeyboard(context, new Handler(), this); for (int i = 0; i < realId.length; i++) realId[i] = -1; handle = new Handler(); this.app = activity; this.context = context; this.sleepTime = config.touchSleepTime; touchHandler = new AndroidMultiTouchHandler(); hasMultitouch = touchHandler.supportsMultitouch(context); vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); int rotation = getRotation(); DisplayMode mode = app.getGraphics().getDesktopDisplayMode(); if (((rotation == 0 || rotation == 180) && (mode.width >= mode.height)) || ((rotation == 90 || rotation == 270) && (mode.width <= mode.height))) { nativeOrientation = Orientation.Landscape; } else { nativeOrientation = Orientation.Portrait; } }
public static void setAccessibilityIgnore(View view) { view.setClickable(false); view.setFocusable(false); view.setContentDescription(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); } }
/** * Add action item * * @param action {@link ActionItem} */ public void addActionItem(QuickActionItem action) { mActionItemList.add(action); String title = action.getTitle(); Drawable icon = action.getIcon(); View container = (View) inflater.inflate(R.layout.action_item, null); ImageView img = (ImageView) container.findViewById(R.id.iv_icon); TextView text = (TextView) container.findViewById(R.id.tv_title); if (icon != null) { img.setImageDrawable(icon); } else { img.setVisibility(View.GONE); } if (title != null) { text.setText(title); } else { text.setVisibility(View.GONE); } final int pos = mChildPos; final int actionId = action.getActionId(); container.setOnClickListener( new OnClickListener() { // @Override public void onClick(View v) { if (mItemClickListener != null) { mItemClickListener.onItemClick(QuickAction.this, pos, actionId); } if (!getActionItem(pos).isSticky()) { mDidAction = true; // workaround for transparent background bug // thx to Roman Wozniak <*****@*****.**> v.post( new Runnable() { // @Override public void run() { dismiss(); } }); } } }); container.setFocusable(true); container.setClickable(true); mTrack.addView(container, mChildPos + 1); mChildPos++; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (position == 0) { final View header = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_header, parent, false) : convertView; // Voicemail controls are only shown in the main UI if there is a voicemail. View voicemailContainer = header.findViewById(R.id.header_voicemail_container); voicemailContainer.setVisibility(mShowVoicemail ? View.VISIBLE : View.GONE); // Call and SMS controls are only shown in the main UI if there is a known number. View callAndSmsContainer = header.findViewById(R.id.header_call_and_sms_container); callAndSmsContainer.setVisibility(mShowCallAndSms ? View.VISIBLE : View.GONE); header.setFocusable(true); header.setOnFocusChangeListener(mHeaderFocusChangeListener); return header; } // Make sure we have a valid convertView to start with final View result = convertView == null ? mLayoutInflater.inflate(R.layout.call_detail_history_item, parent, false) : convertView; PhoneCallDetails details = mPhoneCallDetails[position - 1]; CallTypeIconsView callTypeIconView = (CallTypeIconsView) result.findViewById(R.id.call_type_icon); TextView callTypeTextView = (TextView) result.findViewById(R.id.call_type_text); TextView dateView = (TextView) result.findViewById(R.id.date); TextView durationView = (TextView) result.findViewById(R.id.duration); int callType = details.callTypes[0]; callTypeIconView.clear(); callTypeIconView.add(callType); callTypeTextView.setText(mCallTypeHelper.getCallTypeText(callType)); // Set the date. CharSequence dateValue = DateUtils.formatDateRange( mContext, details.date, details.date, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR); dateView.setText(dateValue); // Set the duration if (callType == Calls.MISSED_TYPE || callType == Calls.VOICEMAIL_TYPE) { durationView.setVisibility(View.GONE); } else { durationView.setVisibility(View.VISIBLE); durationView.setText(formatDuration(details.duration)); } return result; }
public void processProperties(KrollDict d) { if (d.containsKey(TiC.PROPERTY_LAYOUT)) { String layout = TiConvert.toString(d, TiC.PROPERTY_LAYOUT); if (nativeView instanceof TiCompositeLayout) { ((TiCompositeLayout) nativeView).setLayoutArrangement(layout); } } if (TiConvert.fillLayout(d, layoutParams)) { if (nativeView != null) { nativeView.requestLayout(); } } Integer bgColor = null; // Default background processing. // Prefer image to color. if (hasImage(d) || hasColorState(d) || hasBorder(d)) { handleBackgroundImage(d); } else if (d.containsKey(TiC.PROPERTY_BACKGROUND_COLOR)) { bgColor = TiConvert.toColor(d, TiC.PROPERTY_BACKGROUND_COLOR); nativeView.setBackgroundColor(bgColor); } if (d.containsKey(TiC.PROPERTY_OPACITY)) { if (nativeView != null) { setOpacity(TiConvert.toFloat(d, TiC.PROPERTY_OPACITY)); } } if (d.containsKey(TiC.PROPERTY_VISIBLE)) { nativeView.setVisibility( TiConvert.toBoolean(d, TiC.PROPERTY_VISIBLE) ? View.VISIBLE : View.INVISIBLE); } if (d.containsKey(TiC.PROPERTY_ENABLED)) { nativeView.setEnabled(TiConvert.toBoolean(d, TiC.PROPERTY_ENABLED)); } if (d.containsKey(TiC.PROPERTY_FOCUSABLE)) { boolean focusable = TiConvert.toBoolean(d, TiC.PROPERTY_FOCUSABLE); nativeView.setFocusable(focusable); if (focusable) { registerForKeyClick(nativeView); } else { nativeView.setOnClickListener(null); } } initializeBorder(d, bgColor); if (d.containsKey(TiC.PROPERTY_TRANSFORM)) { Ti2DMatrix matrix = (Ti2DMatrix) d.get(TiC.PROPERTY_TRANSFORM); if (matrix != null) { applyTransform(matrix); } } }
@Override public PredictionsAdapterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { int layoutId = viewType == VIEW_TYPE_EXPANDED ? R.layout.list_item_prediction_expanded : R.layout.list_item_prediction; View view = LayoutInflater.from(viewGroup.getContext()).inflate(layoutId, viewGroup, false); view.setFocusable(true); return new PredictionsAdapterViewHolder(view); }
@Override protected void onFinishInflate() { // TODO Auto-generated method stub super.onFinishInflate(); View child; for (int i = 0; i < getChildCount(); i++) { child = getChildAt(i); child.setFocusable(true); child.setClickable(true); } }
public AndroidGraphics( AndroidApplication activity, AndroidApplicationConfiguration config, ResolutionStrategy resolutionStrategy) { this.config = config; view = createGLSurfaceView(activity, config.useGL20, resolutionStrategy); setPreserveContext(view); view.setFocusable(true); view.setFocusableInTouchMode(true); this.app = activity; }
/** @param context everything needs a context :( */ public GlobalScreenshot(Context context) { Resources r = context.getResources(); mContext = context; LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Inflate the screenshot layout mDisplayMatrix = new Matrix(); mScreenshotLayout = layoutInflater.inflate(R.layout.global_screenshot, null); mBackgroundView = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot_background); mScreenshotView = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot); mScreenshotFlash = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot_flash); mScreenshotLayout.setFocusable(true); mScreenshotLayout.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // Intercept and ignore all touch events return true; } }); // Setup the window that we are going to use mWindowLayoutParams = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0, 0, WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, PixelFormat.TRANSLUCENT); mWindowLayoutParams.setTitle("ScreenshotAnimation"); mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mDisplay = mWindowManager.getDefaultDisplay(); mDisplayMetrics = new DisplayMetrics(); mDisplay.getRealMetrics(mDisplayMetrics); // Get the various target sizes mNotificationIconSize = r.getDimensionPixelSize(android.R.dimen.notification_large_icon_height); // Scale has to account for both sides of the bg mBgPadding = (float) r.getDimensionPixelSize(R.dimen.global_screenshot_bg_padding); mBgPaddingScale = mBgPadding / mDisplayMetrics.widthPixels; // Setup the Camera shutter sound mCameraSound = new CameraSound(); }
private void addTab(final int position, View tab) { tab.setFocusable(true); tab.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView( tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
@Override public ArticleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (parent instanceof RecyclerView) { // View view = getLayoutInflater().inflate(R.layout.list_item_article, parent, false); View view = LayoutInflater.from(parent.getContext()) .inflate(R.layout.list_item_article, parent, false); view.setFocusable(true); // some a11y-stuff... return new ArticleViewHolder(view); } else { throw new RuntimeException("Not bound to RecyclerView"); } }
public static void setTitleButton(final Activity activity, final Intent up) { View button = activity.findViewById(R.id.title_button); button.findViewById(R.id.title_up_icon).setVisibility(View.VISIBLE); button.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { activity.startActivity(up.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); } }); button.setFocusable(true); }
protected boolean updateVisibility(boolean visible) { if (visible != (view.getVisibility() == View.VISIBLE)) { if (visible) { view.setVisibility(View.VISIBLE); } else { view.setVisibility(View.GONE); } view.invalidate(); if (app.accessibilityEnabled()) view.setFocusable(visible); return true; } return false; }
protected void a(View paramView, a parama, int paramInt) { parama.a(paramView); ImageView localImageView = (ImageView) paramView.findViewById(2131362474); paramView = (TextView) paramView.findViewById(2131362475); localImageView.setImageDrawable(parama.getIcon()); paramView.setText(parama.getTitle()); paramView.setEnabled(false); paramView.setFocusable(false); localImageView.setEnabled(false); localImageView.setFocusable(false); if (parama.d() == null) { parama.a(new ir(this)); } }
/** * 当Fragment改变时,改变左侧对应条目的背景颜色,并实现ScrollView自动滚动到焦点位置 * * @param clickedView */ public void setLeftTextViewBackgroundColorWhenFragmentChanged(String leftTextViewTag) { Fragment fragmentLeft = activity.getSupportFragmentManager().findFragmentById(R.id.fragment_left); View leftView = fragmentLeft.getView(); View clickedLeftTextView = leftView.findViewWithTag(leftTextViewTag); ScrollView scrollView = (ScrollView) leftView.findViewById(R.id.scrollView_left); clickedLeftTextView.setFocusable(true); clickedLeftTextView.requestFocus(); // view获取焦点 if (leftTextViewTag.equals("0") || leftTextViewTag.equals("1") || leftTextViewTag.equals("2")) scrollView.fullScroll(ScrollView.FOCUS_FORWARD); // 向前滚动 else scrollView.fullScroll(ScrollView.FOCUS_DOWN); // 向后滚动 Log.i(getClass().toString(), "clickedLeftTextView:" + clickedLeftTextView); setLeftTextViewBackgroundColor(clickedLeftTextView, Integer.parseInt(leftTextViewTag)); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater factory = LayoutInflater.from(this); // Set game layout view = factory.inflate(R.layout.main, null); setContentView(view); // Enable view key events view.setFocusable(true); view.setFocusableInTouchMode(true); }
@Override public boolean setViewValue(View view, Object data, String textRepresentation) { if (view.getId() == R.id.userimage_imageview) { view.setFocusable(false); view.setBackgroundResource(R.drawable.ic_launcher); } // if (view instanceof WebView) { // view.setFocusable(false); // } return false; }