当前位置: 首页>>代码示例>>Java>>正文


Java View.setFocusable方法代码示例

本文整理汇总了Java中android.view.View.setFocusable方法的典型用法代码示例。如果您正苦于以下问题:Java View.setFocusable方法的具体用法?Java View.setFocusable怎么用?Java View.setFocusable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.setFocusable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isShouldHideInput

import android.view.View; //导入方法依赖的package包/类
public boolean isShouldHideInput(View v, MotionEvent event) {
        if (v != null && (v instanceof EditText)) {
            int[] leftTop = {0, 0};
            //获取输入框当前的location位置
            v.getLocationInWindow(leftTop);
            int left = leftTop[0];
            int top = leftTop[1];
            int bottom = top + v.getHeight();
            int right = left + v.getWidth();
            if (event.getX() > left && event.getX() < right
                    && event.getY() > top && event.getY() < bottom) {
                // 点击的是输入框区域,保留点击EditText的事件
                return false;
            } else {
                //使EditText触发一次失去焦点事件
                v.setFocusable(false);
//                v.setFocusable(true); //这里不需要是因为下面一句代码会同时实现这个功能
                v.setFocusableInTouchMode(true);
                return true;
            }
        }
        return false;
    }
 
开发者ID:wendyltan,项目名称:EasyTodo,代码行数:24,代码来源:EventContentActivity.java

示例2: addFocusChangeListener

import android.view.View; //导入方法依赖的package包/类
protected final void addFocusChangeListener(OnFocusChangeListener l){
  View view;
  if(l != null && (view = getRealView()) != null) {
    if( mFocusChangeListeners == null){
      mFocusChangeListeners = new ArrayList<>();
      view.setFocusable(true);
      view.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
          for (OnFocusChangeListener listener : mFocusChangeListeners){
            if(listener != null){
              listener.onFocusChange(hasFocus);
            }
          }
        }
      });
    }
    mFocusChangeListeners.add(l);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:21,代码来源:WXComponent.java

示例3: addTab

import android.view.View; //导入方法依赖的package包/类
private void addTab(final int position, View tab) {
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (pager.getCurrentItem() == position && onTabClickListener != null) {
                onTabClickListener.onCurrentTabClicked(position);
            } else {
                pager.setCurrentItem(position, true);
            }
        }
    });
    addTabDoubleTapListener(position, tab);
    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, tabViewLayoutParams);
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:18,代码来源:PagerSlidingTabStrip.java

示例4: onCreateViewHolder

import android.view.View; //导入方法依赖的package包/类
@Override
public ForecastAdapterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    if ( viewGroup instanceof RecyclerView ) {
        int layoutId = -1;
        switch (viewType) {
            case VIEW_TYPE_TODAY: {
                layoutId = R.layout.list_item_forecast_today;
                break;
            }
            case VIEW_TYPE_FUTURE_DAY: {
                layoutId = R.layout.list_item_forecast;
                break;
            }
        }
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(layoutId, viewGroup, false);
        view.setFocusable(true);
        return new ForecastAdapterViewHolder(view);
    } else {
        throw new RuntimeException("Not bound to RecyclerView");
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:22,代码来源:ForecastAdapter.java

示例5: onClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(final View v) {
	if (!v.isFocused()) {
		v.setFocusable(true);
		v.setFocusableInTouchMode(true);					
		v.requestFocus();
		GuiUtils.setKeypadVisibility(getActivity(), (EditText)v, View.VISIBLE);
		
		// 這裡會先delay再送出event,要不然softkeyboard不會出現				
		/*(new Handler()).postDelayed(new Runnable() {
            public void run() {			            	
            	v.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN , 0, 0, 0));
            	v.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP , 0, 0, 0));
            }
        }, 200);*/
	}
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:18,代码来源:MeterPreferenceDialog.java

示例6: disable

import android.view.View; //导入方法依赖的package包/类
/**
 * Helper function to disable a ViewGroup and all it's children. This draws a new view with z-ordering of integer max
 * that consumes all touch events.
 * @param viewGroup
 */
public static void disable(ViewGroup viewGroup){
    View view = new View(viewGroup.getContext());
    viewGroup.addView(view);
    view.setTag(DISABLE);

    ViewGroup.LayoutParams params = view.getLayoutParams();
    params.height = MATCH_PARENT;
    params.width = MATCH_PARENT;
    view.setLayoutParams(params);

    view.setClickable(true);
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(Color.TRANSPARENT);

    if (Build.VERSION.SDK_INT >= 21) {
        view.setTranslationZ(Integer.MAX_VALUE);
    }
    viewGroup.bringChildToFront(view);
}
 
开发者ID:kevinwang5658,项目名称:backstack,代码行数:26,代码来源:Helper.java

示例7: addTab

import android.view.View; //导入方法依赖的package包/类
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 slut
    }
  });

  tab.setPadding(tabPadding, 0, tabPadding, 0);
  tab.setMinimumWidth(minBredde);
  tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:23,代码来源:PagerSlidingTabStrip.java

示例8: onCreateViewHolder

import android.view.View; //导入方法依赖的package包/类
/**
 * This gets called when each new ViewHolder is created. This happens when the RecyclerView
 * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling.
 *
 * @param viewGroup The ViewGroup that these ViewHolders are contained within.
 * @param viewType  If your RecyclerView has more than one type of item (like ours does) you
 *                  can use this viewType integer to provide a different layout. See
 *                  {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)}
 *                  for more details.
 * @return A new ForecastAdapterViewHolder that holds the View for each list item
 */
@Override
public ForecastAdapterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {

    View view = LayoutInflater
            .from(mContext)
            .inflate(R.layout.forecast_list_item, viewGroup, false);

    view.setFocusable(true);

    return new ForecastAdapterViewHolder(view);
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:23,代码来源:ForecastAdapter.java

示例9: onBindViewHolder

import android.view.View; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    HeaderItem headerItem = ((ListRow) item).getHeaderItem();
    View rootView = viewHolder.view;
    rootView.setFocusable(true);

    ImageView iconView = (ImageView) rootView.findViewById(R.id.header_icon);
    Drawable icon = rootView.getResources().getDrawable(R.drawable.icon_movies, null);
    iconView.setImageDrawable(icon);

    TextView label = (TextView) rootView.findViewById(R.id.header_label);
    label.setText(headerItem.getName());
}
 
开发者ID:ad-on-is,项目名称:chilly,代码行数:14,代码来源:IconHeaderItemPresenter.java

示例10: setAccessibilityIgnore

import android.view.View; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:9,代码来源:UIUtils.java

示例11: setCurrentItem

import android.view.View; //导入方法依赖的package包/类
/**
 * 切换 tab
 * @param position
 */
public void setCurrentItem(int position) {
    for (int i = 0; i < tabCount; i++) {
        View tab = tabsContainer.getChildAt(i);
        tab.setFocusable(true);
        currentPosition = position;
        pager.setCurrentItem(position);
    }
}
 
开发者ID:teisun,项目名称:SunmiUI,代码行数:13,代码来源:PagerSlidingTabStrip.java

示例12: addTab

import android.view.View; //导入方法依赖的package包/类
private void addTab(final int position, View tab) {
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tab.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}
 
开发者ID:teisun,项目名称:SunmiUI,代码行数:13,代码来源:PagerSlidingTabStrip.java

示例13: onCreateViewHolder

import android.view.View; //导入方法依赖的package包/类
/**
 * This gets called when each new ViewHolder is created. This happens when the RecyclerView
 * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling.
 *
 * @param viewGroup The ViewGroup that these ViewHolders are contained within.
 * @param viewType  If your RecyclerView has more than one type of item (like ours does) you
 *                  can use this viewType integer to provide a different layout. See
 *                  {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)}
 *                  for more details.
 * @return A new ForecastAdapterViewHolder that holds the View for each list item
 */
@Override
public ForecastAdapterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {

    int layoutId;

    switch (viewType) {

        case VIEW_TYPE_TODAY: {
            layoutId = R.layout.list_item_forecast_today;
            break;
        }

        case VIEW_TYPE_FUTURE_DAY: {
            layoutId = R.layout.forecast_list_item;
            break;
        }

        default:
            throw new IllegalArgumentException("Invalid view type, value of " + viewType);
    }

    View view = LayoutInflater.from(mContext).inflate(layoutId, viewGroup, false);

    view.setFocusable(true);

    return new ForecastAdapterViewHolder(view);
}
 
开发者ID:rashikaranpuria,项目名称:ubiquitous,代码行数:39,代码来源:ForecastAdapter.java

示例14: addTab

import android.view.View; //导入方法依赖的package包/类
private void addTab(final int position, View tab) {
    tab.setFocusable(true);
    tab.setTag(TAB_INDEX, position);
    tab.setOnClickListener(mTabItemClick);
    int left = Math.max(mItemMinPaddingHorizontal, tab.getPaddingLeft());
    int top = Math.max(mItemMinPaddingTop, tab.getPaddingTop());
    int right = Math.max(mItemMinPaddingHorizontal, tab.getPaddingRight());
    int bottom = Math.max(mItemMinPaddingBottom, tab.getPaddingBottom());
    tab.setPadding(left, top, right, bottom);
    if (tab.getLayoutParams() == null) {
        addView(tab, position, mItemLayoutParams);
    } else {
        addView(tab, position);
    }
}
 
开发者ID:rexyren,项目名称:PageScrollView,代码行数:16,代码来源:PageScrollTab.java

示例15: showSoftKeyboard

import android.view.View; //导入方法依赖的package包/类
/**
 * 显示软键盘
 *
 * @param view
 */
public static void showSoftKeyboard(View view) {
    Context context = view.getContext();
    InputMethodManager imm = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:15,代码来源:KeyBordUtil.java


注:本文中的android.view.View.setFocusable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。