Java Code Examples for androidx.appcompat.widget.Toolbar#setTitle()

The following examples show how to use androidx.appcompat.widget.Toolbar#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfileManagerActivity.java    From Maying with Apache License 2.0 6 votes vote down vote up
/**
 * init toolbar
 */
private void initToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.profiles);
    toolbar.setNavigationIcon(R.drawable.ic_navigation_close);
    toolbar.setNavigationOnClickListener(v -> {
        Intent intent = getParentActivityIntent();
        if (shouldUpRecreateTask(intent) || isTaskRoot()) {
            TaskStackBuilder.create(ProfileManagerActivity.this).addNextIntentWithParentStack(intent).startActivities();
        } else {
            finish();
        }
    });
    toolbar.inflateMenu(R.menu.profile_manager_menu);
    toolbar.setOnMenuItemClickListener(this);
}
 
Example 2
Source File: ScannerActivity.java    From Maying with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_scanner);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(getTitle());
    toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            navigateUp();
        }
    });

    scannerView = (ZXingScannerView) findViewById(R.id.scanner);

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager service = getSystemService(ShortcutManager.class);
        if (service != null) {
            service.reportShortcutUsed("scan");
        }
    }
}
 
Example 3
Source File: SelectFragment.java    From shaky-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    FeedbackTypeAdapter adapter = new FeedbackTypeAdapter(getActivity(), getData());

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.shaky_recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(adapter);

    Toolbar toolbar = (Toolbar) view.findViewById(R.id.shaky_toolbar);
    toolbar.setTitle(R.string.shaky_feedback_title);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
}
 
Example 4
Source File: MainActivity.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.app_name);
  setSupportActionBar(toolbar);

  setupTabs();
}
 
Example 5
Source File: Shadowsocks.java    From ShadowsocksRR with Apache License 2.0 5 votes vote down vote up
/**
 * init toolbar
 */
private void initToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    // non-translatable logo
    toolbar.setTitle("shadowsocks R");
    toolbar.setTitleTextAppearance(toolbar.getContext(), R.style.Toolbar_Logo);
    try {
        Field field = Toolbar.class.getDeclaredField("mTitleTextView");
        field.setAccessible(true);
        TextView title = (TextView) field.get(toolbar);
        title.setFocusable(true);
        title.setGravity(0x10);
        title.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
        title.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(Shadowsocks.this, ProfileManagerActivity.class));
            }
        });
        TypedArray typedArray = obtainStyledAttributes(new int[]{R.attr.selectableItemBackgroundBorderless});
        title.setBackgroundResource(typedArray.getResourceId(0, 0));
        typedArray.recycle();
        Typeface tf = Typefaces.get(this, "fonts/Iceland.ttf");
        if (tf != null) {
            title.setTypeface(tf);
        }
        title.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: ShadowsocksQuickSwitchActivity.java    From ShadowsocksRR with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_quick_switch);
    profilesAdapter = new ProfilesAdapter();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.quick_switch);

    RecyclerView profilesList = (RecyclerView) findViewById(R.id.profilesList);
    LinearLayoutManager lm = new LinearLayoutManager(this);
    profilesList.setLayoutManager(lm);
    profilesList.setItemAnimator(new DefaultItemAnimator());
    profilesList.setAdapter(profilesAdapter);
    if (app.profileId() >= 0) {
        int position = 0;
        List<Profile> profiles = profilesAdapter.profiles;
        for (int i = 0; i < profiles.size(); i++) {
            Profile profile = profiles.get(i);
            if (profile.id == app.profileId()) {
                position = i + 1;
                break;
            }
        }
        lm.scrollToPosition(position);
    }

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager service = getSystemService(ShortcutManager.class);
        if (service != null) {
            service.reportShortcutUsed("switch");
        }
    }
}
 
Example 7
Source File: DrawEditorActivity.java    From kolabnotes-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_draweditor);

    toolbar = (Toolbar) findViewById(R.id.toolbar_draweditor);
    if (toolbar != null) {
        toolbar.setTitle(R.string.draweditor_title);
    }

    drawEditorFragment = (DrawEditorFragment) getFragmentManager().findFragmentById(R.id.draweditor_fragment);
}
 
Example 8
Source File: BaseToolbarFragment.java    From Jockey with Apache License 2.0 5 votes vote down vote up
protected void setUpToolbar(Toolbar toolbar) {
    toolbar.setTitle(getFragmentTitle());

    setActivitySupportActionBar(toolbar);
    ActionBar actionBar = getActivitySupportActionBar();

    if (actionBar != null) {
        boolean showUpButton = canNavigateUp();
        actionBar.setDisplayHomeAsUpEnabled(showUpButton);
        actionBar.setHomeButtonEnabled(showUpButton);
        actionBar.setDisplayShowHomeEnabled(showUpButton);

        actionBar.setHomeAsUpIndicator(getUpButtonDrawable());
    }
}
 
Example 9
Source File: SettingsActivity.java    From LocationShare with GNU General Public License v3.0 5 votes vote down vote up
private void setToolbar() {
    LinearLayout root = (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
    Toolbar toolbar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.toolbar, root, false);
    root.addView(toolbar, 0);
    toolbar.setTitle(R.string.settings);
    toolbar.setNavigationOnClickListener(v -> finish());
}
 
Example 10
Source File: MainActivity.java    From meat-grinder with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle("");
    setSupportActionBar(toolbar);
    mProgress = findViewById(R.id.result_progress);
    mProgress.setVisibility(View.GONE);
    mResultState = findViewById(R.id.result_image_view);
    mList = findViewById(R.id.list);
    mList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    mList.setAdapter(new ResultAdapter());
    mFapMe = findViewById(R.id.fab);
    mFapMe.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mTask != null) {
                mTask.cancel(false);
            }
            mTask = new CheckTask(MainActivity.this, false);
            mTask.execute((Void[]) null);
        }
    });
    mTask = new CheckTask(MainActivity.this, true);
    mTask.execute((Void[]) null);

}
 
Example 11
Source File: CollapsingToolbarLayoutActivity.java    From Android-skin-support with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collapsing_toolbar_layout);
    mIvPlaceholder = (ImageView) findViewById(R.id.main_iv_placeholder);
    mLlTitleContainer = (LinearLayout) findViewById(R.id.main_ll_title_container);
    mFlTitleContainer = (FrameLayout) findViewById(R.id.main_fl_title);
    mAblAppBar = (AppBarLayout) findViewById(R.id.main_abl_app_bar);
    mTvToolbarTitle = (TextView) findViewById(R.id.main_tv_toolbar_title);
    mTbToolbar = (Toolbar) findViewById(R.id.main_tb_toolbar);
    mTbToolbar.setTitle("");

    // AppBar的监听
    mAblAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            int maxScroll = appBarLayout.getTotalScrollRange();
            float percentage = (float) Math.abs(verticalOffset) / (float) maxScroll;
            handleAlphaOnTitle(percentage);
            handleToolbarTitleVisibility(percentage);
        }
    });

    findViewById(R.id.small_photo).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(CollapsingToolbarLayoutActivity.this, SettingsActivity.class));
        }
    });

    initParallaxValues(); // 自动滑动效果
}
 
Example 12
Source File: ConfigIntroFragment.java    From prayer-times-android with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.intro_config, container, false);


    Toolbar toolbar = mView.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.appName);
    toolbar.setNavigationIcon(MaterialDrawableBuilder.with(getActivity())
            .setIcon(MaterialDrawableBuilder.IconValue.MENU)
            .setColorResource(R.color.white)
            .setToActionbarSize()
            .build());

    try {
        MaterialMenuInflater.with(getActivity(), getActivity().getMenuInflater())
                .setDefaultColorResource(R.color.white)
                .inflate(R.menu.vakit, toolbar.getMenu());
        mMenuItem = toolbar.getMenu().getItem(0);
        mMenuItem.setIcon(mMenuItem.getIcon());
    } catch (Exception e) {
        e.printStackTrace();
        Crashlytics.logException(e);
    }


    return mView;
}
 
Example 13
Source File: NowPlayingFragment.java    From Jockey with Apache License 2.0 4 votes vote down vote up
private void setupToolbar(Toolbar toolbar) {
    if (getResources().getConfiguration().orientation != ORIENTATION_LANDSCAPE) {
        toolbar.setBackground(new ColorDrawable(Color.TRANSPARENT));
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        toolbar.setElevation(getResources().getDimension(R.dimen.header_elevation));
    }

    toolbar.setTitle("");
    toolbar.setNavigationIcon(R.drawable.ic_clear_24dp);

    toolbar.inflateMenu(R.menu.activity_now_playing);
    toolbar.setOnMenuItemClickListener(this);
    toolbar.setNavigationOnClickListener(v -> {
        getActivity().onBackPressed();
    });

    mCreatePlaylistMenuItem = toolbar.getMenu().findItem(R.id.menu_now_playing_save);
    mAppendToPlaylistMenuItem = toolbar.getMenu().findItem(R.id.menu_now_playing_append);
    mShuffleMenuItem = toolbar.getMenu().findItem(R.id.menu_now_playing_shuffle);
    mRepeatMenuItem = toolbar.getMenu().findItem(R.id.menu_now_playing_repeat);

    toolbar.getMenu().findItem(R.id.menu_open_equalizer)
            .setEnabled(EqualizerActivity.newIntent(getContext(), false) != null);

    mPlayerController.getQueue()
            .compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
            .map(this::queueContainsLocalSongs)
            .subscribe(this::updatePlaylistActionEnabled, throwable -> {
                Timber.e(throwable, "Failed to update playlist enabled state");
            });

    mPlayerController.isShuffleEnabled()
            .compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
            .subscribe(this::updateShuffleIcon, throwable -> {
                Timber.e(throwable, "Failed to update shuffle icon");
            });

    mPlayerController.getRepeatMode()
            .compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
            .subscribe(this::updateRepeatIcon, throwable -> {
                Timber.e(throwable, "Failed to update repeat icon");
            });
}
 
Example 14
Source File: LoginSignUpFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public void setupToolbarDetails(Toolbar toolbar) {
  toolbar.setTitle("");
}
 
Example 15
Source File: WiFiScanActivity.java    From esp-idf-provisioning-android with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wifi_scan_list);
    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.title_activity_wifi_scan_list);
    setSupportActionBar(toolbar);

    ivRefresh = findViewById(R.id.btn_refresh);
    wifiListView = findViewById(R.id.wifi_ap_list);
    progressBar = findViewById(R.id.wifi_progress_indicator);

    progressBar.setVisibility(View.VISIBLE);

    wifiAPList = new ArrayList<>();
    handler = new Handler();
    provisionManager = ESPProvisionManager.getInstance(getApplicationContext());

    String deviceName = provisionManager.getEspDevice().getDeviceName();
    String wifiMsg = String.format(getString(R.string.setup_instructions), deviceName);
    TextView tvWifiMsg = findViewById(R.id.wifi_message);
    tvWifiMsg.setText(wifiMsg);

    ivRefresh.setOnClickListener(refreshClickListener);
    adapter = new WiFiListAdapter(this, R.id.tv_wifi_name, wifiAPList);

    // Assign adapter to ListView
    wifiListView.setAdapter(adapter);
    wifiListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {

            Log.d(TAG, "Device to be connected -" + wifiAPList.get(pos));
            String ssid = wifiAPList.get(pos).getWifiName();

            if (ssid.equals(getString(R.string.join_other_network))) {
                askForNetwork(wifiAPList.get(pos).getWifiName(), wifiAPList.get(pos).getSecurity());
            } else if (wifiAPList.get(pos).getSecurity() == ESPConstants.WIFI_OPEN) {
                goForProvisioning(wifiAPList.get(pos).getWifiName(), "");
            } else {
                askForNetwork(wifiAPList.get(pos).getWifiName(), wifiAPList.get(pos).getSecurity());
            }
        }
    });

    wifiListView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
        }
    });

    startWifiScan();
}
 
Example 16
Source File: InboxFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override protected void setupToolbarDetails(Toolbar toolbar) {
  super.setupToolbarDetails(toolbar);
  toolbar.setTitle(getString(R.string.myaccount_header_title));
}
 
Example 17
Source File: LocalPlayerActivity.java    From CastVideos-android with Apache License 2.0 4 votes vote down vote up
private void setupActionBar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(mSelectedMedia.getMetadata().getString(MediaMetadata.KEY_TITLE));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example 18
Source File: StoreTabGridRecyclerFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void setupToolbarDetails(Toolbar toolbar) {
  toolbar.setTitle(Translator.translate(title, getContext().getApplicationContext(), marketName));
  toolbar.setLogo(R.drawable.logo_toolbar);
}
 
Example 19
Source File: SinglePostView.java    From Hify with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    ViewPump.init(ViewPump.builder()
            .addInterceptor(new CalligraphyInterceptor(
                    new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/bold.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build()))
            .build());

    setContentView(R.layout.activity_single_post_view);

    String post_id=getIntent().getStringExtra("post_id");

    Toolbar toolbar=findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("Post");

    getSupportActionBar().setTitle("Post");
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if(!TextUtils.isEmpty(post_id)){

        boolean forComment=getIntent().getBooleanExtra("forComment",false);

        pbar=findViewById(R.id.pbar);
        mFirestore=FirebaseFirestore.getInstance();

        statsheetView = getLayoutInflater().inflate(R.layout.stat_bottom_sheet_dialog, null);
        mmBottomSheetDialog = new BottomSheetDialog(this);
        mmBottomSheetDialog.setContentView(statsheetView);
        mmBottomSheetDialog.setCanceledOnTouchOutside(true);

        mPostsList = new ArrayList<>();

        if(forComment)
            mAdapter = new PostsAdapter(mPostsList, this,this,mmBottomSheetDialog,statsheetView,true);
        else
            mAdapter = new PostsAdapter(mPostsList, this,this,mmBottomSheetDialog,statsheetView,false);


        RecyclerView mRecyclerView=findViewById(R.id.recyclerView);
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setAdapter(mAdapter);

        pbar.setVisibility(View.VISIBLE);
        getPosts(post_id);



    }else{
        finish();
    }

}
 
Example 20
Source File: MyStoresFragment.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public void setupToolbarDetails(Toolbar toolbar) {
  toolbar.setTitle(null);
  toolbar.setLogo(null);
}