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


Java Toolbar.setNavigationContentDescription方法代码示例

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


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

示例1: getToolbarNavigationIcon

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
public static View getToolbarNavigationIcon(Toolbar toolbar) {
    // https://gist.github.com/NikolaDespotoski/bb963f9b8f40beb954a0

    //check if contentDescription previously was set
    boolean hadContentDescription = TextUtils.isEmpty(toolbar.getNavigationContentDescription());
    String contentDescription = !hadContentDescription ? toolbar.getNavigationContentDescription().toString() : "navigationIcon";
    toolbar.setNavigationContentDescription(contentDescription);
    ArrayList<View> potentialViews = new ArrayList<View>();
    //find the view based on it's content description, set programatically or with android:contentDescription
    toolbar.findViewsWithText(potentialViews, contentDescription, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
    //Nav icon is always instantiated at this point because calling setNavigationContentDescription ensures its existence
    View navIcon = null;
    if (potentialViews.size() > 0) {
        navIcon = potentialViews.get(0); //navigation icon is ImageButton
    }
    //Clear content description if not previously present
    if (hadContentDescription)
        toolbar.setNavigationContentDescription(null);
    return navIcon;
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:21,代码来源:Util.java

示例2: ActionBarDrawerToggle

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
public ActionBarDrawerToggle(Toolbar toolbar, LockableDrawerLayout drawerLayout,
                             int openTextId, int closeTextId) {
    mDrawable = new DrawerArrowDrawable(toolbar.getContext());
    mToolbar = toolbar;
    mOpenTextId = openTextId;
    mCloseTextId = closeTextId;
    drawerLayout.addDrawerListener(this);
    toolbar.setNavigationIcon(mDrawable);
    toolbar.setNavigationContentDescription(drawerLayout.isDrawerOpen(Gravity.START)
            ? closeTextId : openTextId);
    toolbar.setNavigationOnClickListener((View view) -> {
        if (drawerLayout.isDrawerOpen(Gravity.START))
            drawerLayout.closeDrawer(Gravity.START, !drawerLayout.isCurrentlyLocked());
        else
            drawerLayout.openDrawer(Gravity.START, !drawerLayout.isCurrentlyLocked());
        drawerLayout.requestLayout();
    });
    mOpenTextId = openTextId;
    mCloseTextId = closeTextId;
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:21,代码来源:LockableDrawerLayout.java

示例3: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.session_feedback_act);

    if (savedInstanceState == null) {
        Uri sessionUri = getIntent().getData();
        BeamUtils.setBeamSessionUri(this, sessionUri);
    }

    mSessionUri = getIntent().getData();

    if (mSessionUri == null){
        LOGE(TAG, "SessionFeedbackActivity started with null data URI!");
        finish();
    }

    addPresenterFragment(R.id.session_feedback_frag,
            new SessionFeedbackModel(mSessionUri, getApplicationContext(),
                    new FeedbackHelper(this)),
            SessionFeedbackModel.SessionFeedbackQueryEnum.values(),
            SessionFeedbackModel.SessionFeedbackUserActionEnum.values());


    Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(R.drawable.ic_up);
    toolbar.setNavigationContentDescription(R.string.close_and_go_back);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            NavUtils.navigateUpTo(SessionFeedbackActivity.this,
                    getParentActivityIntent());
        }
    });
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:36,代码来源:SessionFeedbackActivity.java

示例4: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    UIUtils.tryTranslateHttpIntent(this);
    BeamUtils.tryUpdateIntentFromBeam(this);
    boolean shouldBeFloatingWindow = shouldBeFloatingWindow();
    if (shouldBeFloatingWindow) {
        setupFloatingWindow(R.dimen.session_details_floating_width,
                R.dimen.session_details_floating_height, 1, 0.4f);
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.session_detail_act);

    final Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(shouldBeFloatingWindow
            ? R.drawable.ic_ab_close : R.drawable.ic_up);
    toolbar.setNavigationContentDescription(R.string.close_and_go_back);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            // Do not display the Activity name in the toolbar
            toolbar.setTitle("");
        }
    });

    if (savedInstanceState == null) {
        Uri sessionUri = getIntent().getData();
        BeamUtils.setBeamSessionUri(this, sessionUri);
    }

    mSessionUri = getIntent().getData();

    if (mSessionUri == null) {
        LOGE(TAG, "SessionDetailActivity started with null session Uri!");
        finish();
        return;
    }

    addPresenterFragment(R.id.session_detail_frag,
            new SessionDetailModel(mSessionUri, getApplicationContext(),
                    new SessionsHelper(this)), SessionDetailQueryEnum.values(),
            SessionDetailUserActionEnum.values());
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:50,代码来源:SessionDetailActivity.java

示例5: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.explore_sessions_act);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerCollectionView = (CollectionView) findViewById(R.id.drawer_collection_view);
    mTimeSlotLayout = findViewById(R.id.timeslot_view);
    mTimeSlotDivider = findViewById(R.id.timeslot_divider);
    TextView timeSlotTextView = (TextView) findViewById(R.id.timeslot);
    ImageButton dismissTimeSlotButton = (ImageButton) findViewById(R.id.close_timeslot);
    registerHideableHeaderView(findViewById(R.id.headerbar));

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_flipped, GravityCompat.END);

    mFragment = (ExploreSessionsFragment) getFragmentManager()
            .findFragmentById(R.id.explore_sessions_frag);

    if (savedInstanceState != null) {

        mTagFilterHolder = savedInstanceState.getParcelable(STATE_FILTER_TAGS);
        mCurrentUri = savedInstanceState.getParcelable(STATE_CURRENT_URI);

    } else if (getIntent() != null) {
        mCurrentUri = getIntent().getData();
    }

    // Build the tag URI
    long[] interval = ScheduleContract.Sessions.getInterval(mCurrentUri);
    if (interval != null) {
        mMode = MODE_TIME_FIT;

        String title = getString(R.string.explore_sessions_time_slot_title,
                getString(R.string.explore_sessions_show_day_n,
                        UIUtils.startTimeToDayIndex(interval[0])),
                UIUtils.formatTime(interval[0], this));
        setTitle(title);

        mTimeSlotLayout.setVisibility(View.VISIBLE);
        mTimeSlotDivider.setVisibility(View.VISIBLE);
        timeSlotTextView.setText(title);
        dismissTimeSlotButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mTimeSlotLayout.setVisibility(View.GONE);
                mTimeSlotDivider.setVisibility(View.GONE);
                mMode = MODE_EXPLORE;
                mCurrentUri = null;
                reloadFragment();
            }
        });
    } else {
        mMode = MODE_EXPLORE;
    }

    // Add the back button to the toolbar.
    Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(R.drawable.ic_up);
    toolbar.setNavigationContentDescription(R.string.close_and_go_back);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            navigateUpOrBack(ExploreSessionsActivity.this, null);
        }
    });

    // Start loading the tag metadata. This will in turn call the fragment with the
    // correct arguments.
    getLoaderManager().initLoader(TAG_METADATA_TOKEN, null, this);

    // ANALYTICS SCREEN: View the Explore Sessions screen
    // Contains: Nothing (Page name is a constant)
    AnalyticsHelper.sendScreenView(SCREEN_LABEL);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:75,代码来源:ExploreSessionsActivity.java

示例6: onCreate

import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get the initial filter values from the intent call.
    Bundle extras = getIntent().getExtras();
    setTitle(R.string.title_video_library);
    String topicFilter = VideoLibraryModel.ALL_TOPICS;
    int yearFilter = VideoLibraryModel.ALL_YEARS;
    if (extras != null) {
        topicFilter = extras.getString(KEY_FILTER_TOPIC, VideoLibraryModel.ALL_TOPICS);
        yearFilter = extras.getInt(KEY_FILTER_YEAR, VideoLibraryModel.ALL_YEARS);
    }

    // Instantiate a new model with initial filter values from the intent call.
    VideoLibraryModel model = new VideoLibraryModel(getApplicationContext(), this);
    model.setSelectedTopic(topicFilter);
    model.setSelectedYear(yearFilter);

    setContentView(R.layout.video_library_filtered_act);

    addPresenterFragment(R.id.video_library_frag, model, VideoLibraryQueryEnum.values(),
            VideoLibraryUserActionEnum.values());

    // ANALYTICS EVENT: View the Filtered Video Library screen
    // Contains: Nothing (Page name is a constant)
    AnalyticsHelper.sendScreenView(SCREEN_LABEL);
    LOGD("Tracker", SCREEN_LABEL);

    registerHideableHeaderView(findViewById(R.id.headerbar));

    // Add the back button to the toolbar.
    Toolbar toolbar = getActionBarToolbar();
    toolbar.setNavigationIcon(R.drawable.ic_up);
    toolbar.setNavigationContentDescription(R.string.close_and_go_back);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            navigateUpOrBack(VideoLibraryFilteredActivity.this, null);
        }
    });
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:44,代码来源:VideoLibraryFilteredActivity.java


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