當前位置: 首頁>>代碼示例>>Java>>正文


Java IdRes類代碼示例

本文整理匯總了Java中android.support.annotation.IdRes的典型用法代碼示例。如果您正苦於以下問題:Java IdRes類的具體用法?Java IdRes怎麽用?Java IdRes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IdRes類屬於android.support.annotation包,在下文中一共展示了IdRes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addOnClickListener

import android.support.annotation.IdRes; //導入依賴的package包/類
/**
 * add childView id
 *
 * @param viewId add the child view id   can support childview click
 * @return if you use adapter bind listener
 * @link {(adapter.setOnItemChildClickListener(listener))}
 * <p>
 * or if you can use  recyclerView.addOnItemTouch(listerer)  wo also support this menthod
 */
@SuppressWarnings("unchecked")
public BaseViewHolder addOnClickListener(@IdRes final int viewId) {
    childClickViewIds.add(viewId);
    final View view = getView(viewId);
    if (view != null) {
        if (!view.isClickable()) {
            view.setClickable(true);
        }
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (adapter.getOnItemChildClickListener() != null) {
                    adapter.getOnItemChildClickListener().onItemChildClick(adapter, v, getClickPosition());
                }
            }
        });
    }

    return this;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:BaseViewHolder.java

示例2: setupNavigationButton

import android.support.annotation.IdRes; //導入依賴的package包/類
private void setupNavigationButton(@NonNull View view, @IdRes int buttonId, @IdRes int imageId) {
    FrameLayout frameButton = view.findViewById(buttonId);
    frameButton.setOnClickListener(this);
    frameButton.setOnLongClickListener(this);
    ImageView buttonImage = view.findViewById(imageId);
    buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:8,代碼來源:BookmarksFragment.java

示例3: onCheckedChanged

import android.support.annotation.IdRes; //導入依賴的package包/類
@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
    switch (checkedId) {
        case R.id.home_radio:
            changeFragment(HOME_RADIO_BUTTON_INDEX);
            break;
        case R.id.found_radio:
            changeFragment(FOUND_RADIO_BUTTON_INDEX);
            break;
        case R.id.follow_radio:
            changeFragment(FOLLOW_RADIO_BUTTON_INDEX);
            break;
        case R.id.mine_radio:
            changeFragment(MINE_RADIO_BUTTON_INDEX);
            break;
        default:
            break;
    }
}
 
開發者ID:KnowledgeBegger,項目名稱:MyEyepetizer,代碼行數:20,代碼來源:MainActivity.java

示例4: initFragment

import android.support.annotation.IdRes; //導入依賴的package包/類
protected <T extends Fragment> T initFragment(@IdRes int target,
                                              @NonNull T fragment,
                                              @NonNull MasterSecret masterSecret,
                                              @Nullable Locale locale,
                                              @Nullable Bundle extras)
{
  Bundle args = new Bundle();
  args.putParcelable("master_secret", masterSecret);
  args.putSerializable(LOCALE_EXTRA, locale);

  if (extras != null) {
    args.putAll(extras);
  }

  fragment.setArguments(args);
  getSupportFragmentManager().beginTransaction()
                             .replace(target, fragment)
                             .commit();
  return fragment;
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:21,代碼來源:PassphraseRequiredActionBarActivity.java

示例5: addFragments

import android.support.annotation.IdRes; //導入依賴的package包/類
/**
 * 新增多個fragment
 *
 * @param fragmentManager fragment管理器
 * @param fragments       fragments
 * @param containerId     布局Id
 * @param showIndex       要顯示的fragment索引
 * @param lists           共享元素鏈表
 * @return 要顯示的fragment
 */
public static Fragment addFragments(@NonNull final FragmentManager fragmentManager,
                                    @NonNull final List<Fragment> fragments,
                                    @IdRes final int containerId,
                                    final int showIndex,
                                    @NonNull final List<SharedElement>... lists) {
    for (int i = 0, size = fragments.size(); i < size; ++i) {
        Fragment fragment = fragments.get(i);
        List<SharedElement> list = lists[i];
        if (fragment != null) {
            if (list != null) {
                putArgs(fragment, new Args(containerId, showIndex != i, false));
                return operateFragment(fragmentManager, null, fragment, TYPE_ADD_FRAGMENT, list.toArray(new SharedElement[0]));
            }
        }
    }
    return fragments.get(showIndex);
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:28,代碼來源:FragmentUtils.java

示例6: addFragments

import android.support.annotation.IdRes; //導入依賴的package包/類
/**
 * 新增多個fragment
 *
 * @param fragmentManager fragment管理器
 * @param fragments       fragments
 * @param containerId     布局Id
 * @param showIndex       要顯示的fragment索引
 * @param lists           共享元素鏈表
 * @return 要顯示的fragment
 */
public static Fragment addFragments(@NonNull FragmentManager fragmentManager,
                                    @NonNull List<Fragment> fragments,
                                    @IdRes int containerId,
                                    int showIndex,
                                    @NonNull List<SharedElement>... lists) {
    for (int i = 0, size = fragments.size(); i < size; ++i) {
        Fragment fragment = fragments.get(i);
        List<SharedElement> list = lists[i];
        if (fragment != null) {
            if (list != null) {
                putArgs(fragment, new Args(containerId, showIndex != i, false));
                return operateFragment(fragmentManager, null, fragment, TYPE_ADD_FRAGMENT, list.toArray(new SharedElement[0]));
            }
        }
    }
    return fragments.get(showIndex);
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:28,代碼來源:FragmentUtils.java

示例7: initializeBottomBar

import android.support.annotation.IdRes; //導入依賴的package包/類
/**
 * set up the navigation tabs at the bottom of the screen
 * navigation items:
 *      dashboard
 *      search
 *      add new habit
 *      follow requests
 *      profile
 */
private void initializeBottomBar() {
    bottomBar = (BottomBar) findViewById(R.id.bottomBar);
    bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
        @Override
        public void onTabSelected(@IdRes int tabId) {
            switch (tabId) {
                case R.id.tab_dashboard:
                    onDashboardClicked();
                    break;
                case R.id.tab_search:
                    onSearchClicked();
                    break;
                case R.id.tab_addHabit:
                    break;
                case R.id.tab_followRequests:
                    onFollowRequestClicked();
                    break;
                case R.id.tab_profile:
                    onProfileClicked();
                    break;
            }
        }
    });

    bottomBar.setTabSelectionInterceptor(new TabSelectionInterceptor() {
        @Override
        public boolean shouldInterceptTabSelection(@IdRes int oldTabId, @IdRes int newTabId) {
            if (newTabId == R.id.tab_addHabit) {
                onAddHabitClicked();
                return true;
            }
            return false;
        }
    });
}
 
開發者ID:CMPUT301F17T15,項目名稱:CIA,代碼行數:45,代碼來源:HomeTabbedActivity.java

示例8: replaceFragmentWithBackStack

import android.support.annotation.IdRes; //導入依賴的package包/類
/**
     * 替換fragement 並添加動畫
     * 替換fragement的同時對fragment進行“入back棧”操作 ,據我所知並不是真正的進入內存棧
     *
     * @param id_content
     * @param anim_in
     * @param anim_out
     * @param fragment
     */
    @Deprecated
    public void replaceFragmentWithBackStack(@IdRes int id_content, @AnimRes int anim_in, @AnimRes int anim_out, Fragment fragment) {
        String tag = fragment.getClass().getSimpleName();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
//        transaction.setCustomAnimations(anim_in, anim_out);
        transaction.replace(id_content, fragment, tag);
        //記錄commit一次操作,與mFragmentManager.popBackStack();匹配使用
        transaction.addToBackStack(tag);
        //commitAllowingStateLoss 優於 commit 方法,當使用commit方法時,係統將進行狀態判斷,如果狀態(mStateSaved)已經保存,將發生"Can not perform this action after onSaveInstanceState"錯誤。
        //如果mNoTransactionsBecause已經存在,將發生"Can not perform this action inside of " + mNoTransactionsBecause錯誤。
        transaction.commitAllowingStateLoss();
    }
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:22,代碼來源:BActivity.java

示例9: bindViewById

import android.support.annotation.IdRes; //導入依賴的package包/類
protected <T> T bindViewById(@IdRes int id) {
    //noinspection unchecked
    if (id < 0 || mBlockingView == null) {
        return null;
    }
    //noinspection unchecked
    return (T) mBlockingView.findViewById(id);
}
 
開發者ID:iflove,項目名稱:UIKit-ViewBlock,代碼行數:9,代碼來源:ViewBlock.java

示例10: setAlpha

import android.support.annotation.IdRes; //導入依賴的package包/類
/**
 * Add an action to set the alpha of a view. Can be called multiple times.
 * Alpha between 0-1.
 */
public BaseViewHolder setAlpha(@IdRes int viewId, float value) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getView(viewId).setAlpha(value);
    } else {
        // Pre-honeycomb hack to set Alpha value
        AlphaAnimation alpha = new AlphaAnimation(value, value);
        alpha.setDuration(0);
        alpha.setFillAfter(true);
        getView(viewId).startAnimation(alpha);
    }
    return this;
}
 
開發者ID:GaoGersy,項目名稱:MultiSelecter,代碼行數:17,代碼來源:BaseViewHolder.java

示例11: getView

import android.support.annotation.IdRes; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public <T extends View> T getView(@IdRes int viewId) {
    View view = views.get(viewId);
    if (view == null) {
        view = itemView.findViewById(viewId);
        views.put(viewId, view);
    }
    return (T) view;
}
 
開發者ID:alphater,項目名稱:garras,代碼行數:10,代碼來源:BaseViewHolder.java

示例12: newInstance

import android.support.annotation.IdRes; //導入依賴的package包/類
public static PgpEnabledErrorDialog newInstance(boolean isGotItDialog, @IdRes int showcaseView) {
    PgpEnabledErrorDialog dialog = new PgpEnabledErrorDialog();

    Bundle args = new Bundle();
    args.putInt(ARG_HIGHLIGHT_VIEW, showcaseView);
    args.putBoolean(ARG_IS_GOTIT, isGotItDialog);
    dialog.setArguments(args);

    return dialog;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:11,代碼來源:PgpEnabledErrorDialog.java

示例13: testTarget

import android.support.annotation.IdRes; //導入依賴的package包/類
@Test
public void testTarget() {
  ViewGroup container1 = new TestContainer(RuntimeEnvironment.application);
  ViewGroup container2 = new TestContainer(RuntimeEnvironment.application);
  @IdRes int containerId1 = 1;
  @IdRes int containerId2 = 2;
  container1.setId(containerId1);
  container2.setId(containerId2);

  Stage stage1 = director.direct(container1);
  Stage stage2 = director.direct(container2);

  Scene scene1 = new TestScene();
  Scene scene2 = new TestScene();
  stage1.pushScene(scene1);
  stage1.pushScene(scene2);

  Scene scene3 = new TestScene();
  Scene scene4 = new TestScene();
  stage2.pushScene(scene3);
  stage2.pushScene(scene4);

  Director director2 = scene2.hireChildDirector();
  Stage stage3 = director2.direct(new TestContainer(RuntimeEnvironment.application));
  Scene scene5 = new TestScene();
  stage3.pushScene(scene5);

  Director director3 = scene3.hireChildDirector();
  Stage stage4 = director3.direct(new TestContainer(RuntimeEnvironment.application));
  Scene scene6 = new TestScene();
  stage4.pushScene(scene6);

  scene5.setTarget(scene6);
  assertEquals(scene6, scene5.getTarget());
}
 
開發者ID:seven332,項目名稱:Stage,代碼行數:36,代碼來源:DirectorTest.java

示例14: Size

import android.support.annotation.IdRes; //導入依賴的package包/類
Size(
    @IdRes int thumbViewId,
    String name,
    String extension,
    int width,
    int height,
    CacheChoice cacheChoice) {
  this.thumbViewId = thumbViewId;
  this.name = name;
  this.uri = Uri.parse(String.format(URI_TEMPLATE, name, extension));
  this.width = width;
  this.height = height;
  this.cacheChoice = cacheChoice;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:MediaVariationsFragment.java

示例15: castView

import android.support.annotation.IdRes; //導入依賴的package包/類
public static <T> T castView(View view, @IdRes int id, String who, Class<T> cls) {
  try {
    return cls.cast(view);
  } catch (ClassCastException e) {
    String name = getResourceEntryName(view, id);
    throw new IllegalStateException("View '"
        + name
        + "' with ID "
        + id
        + " for "
        + who
        + " was of the wrong type. See cause for more info.", e);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:Utils.java


注:本文中的android.support.annotation.IdRes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。