Java Code Examples for android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled()

The following are Jave code examples for showing how to use setDisplayHomeAsUpEnabled() of the android.support.v7.app.ActionBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ClouldReader   File: SlideScrollViewActivity.java   View Source Code Vote up 7 votes
private void setTitleBar() {
        setSupportActionBar(binding.titleToolBar);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            //去除默认Title显示
            actionBar.setDisplayShowTitleEnabled(false);
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
//            actionBar.setTitle(subjectsBean.getTitle());
//            actionBar.setSubtitle("主演:" + StringFormatUtil.formatName(subjectsBean.getCasts()));
        }

        // title
        binding.tvTitle.setText(subjectsBean.getTitle());
        // 副标题
        binding.tvSubtitle.setText("主演:" + StringFormatUtil.formatName(subjectsBean.getCasts()));

        binding.titleToolBar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }
 
Example 2
Project: JKCloud   File: OpportunityListActivity.java   View Source Code Vote up 6 votes
@Override
protected void initData() {
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        paraMap.put("companyId", bundle.getString("CompanyId"));
        if (mToolbar != null) {
            setSupportActionBar(mToolbar);
            ActionBar mActionBar = getSupportActionBar();
            if (mActionBar != null) {
                mActionBar.setDisplayHomeAsUpEnabled(true);
                mActionBar.setTitle("商机报备 -> " + bundle.getString("CompanyShortName"));
            }
        }
    }
    new OpportunityPresenter(this);
    presenter.getData(1, SIZE, paraMap);
}
 
Example 3
Project: rest-android   File: EditRequestActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_request_edit);

    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
        actionBar.setTitle(R.string.title_edit_request);
    }
}
 
Example 4
Project: CatchSpy   File: EditActivity.java   View Source Code Vote up 5 votes
private void setAllView() {
    setContentView(R.layout.activity_edit);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    editListAdapter = new EditListAdapter(this, EditWordMethod.viewExtraWordList(ExtraWordsPath));
    RecyclerView recyclerView = findViewById(R.id.list_edit);
    recyclerView.setAdapter(editListAdapter);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
}
 
Example 5
Project: dkplayer   File: ListFragmentViewPagerActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_fragment_view_pager);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle("LIST FRAGMENT VIEWPAGER");
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    initView();
}
 
Example 6
Project: Kandroid   File: SettingsActivity.java   View Source Code Vote up 5 votes
private void  setupActionBar() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        // Show the Up button in the action bar.
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 7
Project: android-dev-challenge   File: SettingsActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    ActionBar actionBar = this.getSupportActionBar();

    // Set the action bar back button to look like an up button
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 8
Project: NeteaseCloudMusic   File: PlayerActivity.java   View Source Code Vote up 5 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_player);
        ButterKnife.bind(this);

        setSupportActionBar(toolbar);

        toolbar.setNavigationOnClickListener(this);
        ActionBar actionBar = getSupportActionBar();
        if (null != actionBar) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }

        mAdapter = new DiscPagerAdapter(getLayoutInflater());
        mViewPager.setAdapter(mAdapter);

        mDiscChanger = new DiscPageChanger(mViewPager, needle);
        mViewPager.addOnPageChangeListener(mDiscChanger);


        mPresenter = new PlayerPresenter(this);
        mConfigPresenter = new ConfigPresenter(this);

//        mPresenter.setPlaylist(id, position);

//        ivPlay.setImageResource(PlayerManager.newInstance(this).isPause() ? R.drawable.ic_play : R.drawable.ic_pause);


//        setBlurBackground(BitmapFactory.decodeResource(getResources(), R.drawable.play_bg_night));
        orders = getResources().getStringArray(R.array.array_music_order);
        mPresenter.requestMusicInfo();
        mConfigPresenter.requestLoadingList();
    }
 
Example 9
Project: BilibiliClient   File: UserInfoDetailsActivity.java   View Source Code Vote up 5 votes
@Override
public void initToolBar() {

  mToolbar.setTitle("");
  setSupportActionBar(mToolbar);
  ActionBar supportActionBar = getSupportActionBar();
  if (supportActionBar != null) {
    supportActionBar.setDisplayHomeAsUpEnabled(true);
  }

  //设置StatusBar透明
  SystemBarHelper.immersiveStatusBar(this);
  SystemBarHelper.setHeightAndPadding(this, mToolbar);

  //设置AppBar展开折叠状态监听
  mAppBarLayout.addOnOffsetChangedListener(new AppBarStateChangeEvent() {

    @Override
    public void onStateChanged(AppBarLayout appBarLayout, State state, int verticalOffset) {

      if (state == State.EXPANDED) {
        //展开状态
        mCollapsingToolbarLayout.setTitle("");
        mLineView.setVisibility(View.VISIBLE);
      } else if (state == State.COLLAPSED) {
        //折叠状态
        mCollapsingToolbarLayout.setTitle(name);
        mLineView.setVisibility(View.GONE);
      } else {
        mCollapsingToolbarLayout.setTitle("");
        mLineView.setVisibility(View.VISIBLE);
      }
    }
  });
}
 
Example 10
Project: tumbviewer   File: DownloadingActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_downloading);
    Toolbar toolbar = findViewById(R.id.toolBar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.downloading);
    }

    showFragment(new DownloadFragment(), null);
}
 
Example 11
Project: Hello-Music-droid   File: PlaylistFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(
            R.layout.fragment_playlist, container, false);

    Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    pager = (MultiViewPager) rootView.findViewById(R.id.playlistpager);
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);


    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle(R.string.playlists);

    playlists = PlaylistLoader.getPlaylists(getActivity(), showAuto);
    playlistcount = playlists.size();

    if (isDefault) {
        initPager();
    } else {
        initRecyclerView();
    }

    return rootView;

}
 
Example 12
Project: IslamicLibraryAndroid   File: BookInformationMoreDialogFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.dialog_book_info_read_more, container, false);

    Bundle args = getArguments();
    String title = args.getString(KEY_DIALOG_FRAGMENT_TITLE, getResources().getString(R.string.authors));
    Toolbar toolbar = rootView.findViewById(R.id.toolbar);
    toolbar.setTitle(title);

    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

    ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);

        Drawable drawable = getResources()
                .getDrawable(R.drawable.ic_close_white_24dp);
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable, Color.WHITE);
        actionBar.setHomeAsUpIndicator(drawable);
    }


    String body = args.getString(KEY_DIALOG_BODY, getResources().getString(R.string.authors));
    TextView bodyTextView = rootView.findViewById(R.id.more_dialog_body_text_view);
    bodyTextView.setText(body);
    setHasOptionsMenu(true);
    return rootView;
}
 
Example 13
Project: rest-android   File: ResponseDetailsActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_response_details);

    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.title_response_details);
    }
}
 
Example 14
Project: android-dev-challenge   File: SettingsActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    ActionBar actionBar = this.getSupportActionBar();

    // Set the action bar back button to look like an up button
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 15
Project: BilibiliClient   File: BangumiDetailsActivity.java   View Source Code Vote up 5 votes
@Override
public void initToolBar() {
    mToolbar.setTitle("番剧详情");
    setSupportActionBar(mToolbar);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(true);
    }

    // 设置 Toolbar 的透明度
    mToolbar.setBackgroundColor(Color.argb(0, 251, 114, 163));

    // 设置 StatusBar 的透明度
    SystemBarHelper.immersiveStatusBar(this);
    SystemBarHelper.setPadding(this, mToolbar);

    //获取顶部image高度和toolbar高度
    float imageHeight = getResources().getDimension(R.dimen.bangumi_details_top_layout_height);
    float toolBarHeight = getResources().getDimension(R.dimen.action_bar_default_height);

    mNestedScrollView.setNestedScrollingEnabled(true);
    mNestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            // 根据 NestedScrollView 滑动改变 Toolbar 的透明度
            float offsetY = toolBarHeight - imageHeight;
            //计算滑动距离的偏移量
            float offset = 1 - Math.max((offsetY - scrollY) / offsetY, 0f);
            float absOffset = Math.abs(offset);
            //如果滑动距离大于1就设置完全不透明度
            if (absOffset >= 1) {
                absOffset = 1;
            }
            mToolbar.setBackgroundColor(Color.argb((int) (absOffset * 255), 251, 114, 153));
        }
    });
}
 
Example 16
Project: Protestr   File: SettingsActivity.java   View Source Code Vote up 5 votes
/**
 * Set up the {@link android.app.ActionBar}, if the API is available.
 */
private void setupActionBar() {
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        // Show the Up button in the action bar.
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 17
Project: IslamicLibraryAndroid   File: TableOfContentsBookmarksActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((IslamicLibraryApplication) getApplication()).refreshLocale(this, false);
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    int initial_section = intent.getIntExtra(ReadingActivity.KEY_TAB_NAME, 0);
    bookId = intent.getIntExtra(BooksInformationDBContract.BooksAuthors.COLUMN_NAME_BOOK_ID, 0);
    bookName = intent.getStringExtra(BooksInformationDBContract.BookInformationEntery.COLUMN_NAME_TITLE);
    setContentView(R.layout.activity_book_toc_bookmarks);
    bookCardEventsCallback.intializeListener();
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(true);
        supportActionBar.setTitle(bookName);
    }


    SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());


    ViewPager mViewPager = findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    if (intent.hasExtra(BookDatabaseContract.TitlesEntry.COLUMN_NAME_PAGE_ID)) {
        pageId = intent.getIntExtra(BookDatabaseContract.TitlesEntry.COLUMN_NAME_PAGE_ID, 0);
        titleId = intent.getIntExtra(BookDatabaseContract.TitlesEntry.COLUMN_NAME_ID, 0);
        buildHistory = true;
        mViewPager.setCurrentItem(initial_section);
    } else {
        mViewPager.setCurrentItem(initial_section);
    }
    TabLayout tabLayout = findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    mBooksPartInfo = BookDatabaseHelper.getInstance(this, bookId).getBookPartsInfo();
    mIsArabic = Util.isArabicUi(this);


}
 
Example 18
Project: tumbviewer   File: SettingsActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    Toolbar toolbar = findViewById(R.id.toolBar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    findViewById(R.id.settings_register).setOnClickListener(this);
    findViewById(R.id.settings_clear_cache).setOnClickListener(this);
    findViewById(R.id.settings_add_account).setOnClickListener(this);
    findViewById(R.id.settings_option_simple).setOnClickListener(this);

    originalMode = PreferencesUtils.getBoolean(POST_SIMPLE_MODE, false);
    simpleCheckBox = findViewById(R.id.settings_option_simple_checkbox);
    simpleCheckBox.setChecked(originalMode);
    simpleCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            PreferencesUtils.putBoolean(POST_SIMPLE_MODE, isChecked);
            DataManager.getInstance().setSimpleMode(simpleCheckBox.isChecked());
        }
    });

    List<TumblrAccount> tumblrAccounts = DataManager.getInstance().getTumblrAccounts();
    accounts = new ArrayList<>(tumblrAccounts.size());
    accounts.addAll(tumblrAccounts);

    adapter = CommonRVAdapter.newBuilder()
            .addItemType(TumblrAccount.class, R.layout.item_settings_account,
                    new CommonRVAdapter.CreateViewHolder() {
                        @Override
                        public CommonViewHolder createVH(View view) {
                            return new AccountVH(view);
                        }
                    })
            .setData(accounts)
            .build();

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.settings_accounts);
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);
}
 
Example 19
Project: AndiCar   File: StatisticsActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //prevent keyboard from automatic pop up
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    setContentView(R.layout.activity_statistics);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Show the Up button in the action bar.
    //The solution is to change dynamically the parent activity for up navigation
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        return;
    }

    mStatisticsType = extras.getInt(STATISTICS_TYPE_KEY, -1);
    if (mStatisticsType == -1) {
        return;
    }

    mWhereConditions = extras.getBundle(WHERE_CONDITIONS_KEY);

    switch (mStatisticsType) {
        case CommonListActivity.ACTIVITY_TYPE_MILEAGE:
            setTitle(String.format(getString(R.string.title_statistics_activity), getString(R.string.gen_trips)));
            break;
        case CommonListActivity.ACTIVITY_TYPE_REFUEL:
            setTitle(String.format(getString(R.string.title_statistics_activity), getString(R.string.gen_fill_ups)));
            break;
        case CommonListActivity.ACTIVITY_TYPE_EXPENSE:
            setTitle(String.format(getString(R.string.title_statistics_activity), getString(R.string.gen_expenses)));
            break;
        case CommonListActivity.ACTIVITY_TYPE_GPS_TRACK:
            setTitle(String.format(getString(R.string.title_statistics_activity), getString(R.string.gen_gps_tracks)));
            break;
    }

    fillStatistics();

}
 
Example 20
Project: shrinker   File: ItemDetailActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_detail);
    Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own detail action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    // Show the Up button in the action bar.
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    // savedInstanceState is non-null when there is fragment state
    // saved from previous configurations of this activity
    // (e.g. when rotating the screen from portrait to landscape).
    // In this case, the fragment will automatically be re-added
    // to its container so we don't need to manually add it.
    // For more information, see the Fragments API guide at:
    //
    // http://developer.android.com/guide/components/fragments.html
    //
    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.
        Bundle arguments = new Bundle();
        arguments.putString(ItemDetailFragment.ARG_ITEM_ID,
                getIntent().getStringExtra(ItemDetailFragment.ARG_ITEM_ID));
        ItemDetailFragment fragment = new ItemDetailFragment();
        fragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction()
                .add(R.id.item_detail_container, fragment)
                .commit();
    }
}