当前位置: 首页>>代码示例>>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;未经允许,请勿转载。