當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。