Java Code Examples for android.support.v7.widget.Toolbar#findViewById()

The following examples show how to use android.support.v7.widget.Toolbar#findViewById() . 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: BaseActivity.java    From Messenger-Android-XML-Template with GNU General Public License v3.0 5 votes vote down vote up
public final void changeTitle(int toolbarId, String titlePage){
    toolbar = (Toolbar) findViewById(toolbarId);
    setSupportActionBar(toolbar);

    title = (TextView) toolbar.findViewById(R.id.tv_title);
    title.setText(titlePage);
    getSupportActionBar().setTitle("");
}
 
Example 2
Source File: AbsBaseSwipeBackActivity.java    From LLApp with Apache License 2.0 5 votes vote down vote up
private void initToolBar() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(StaticValue.color);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        abTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
    }
    if (abTitle != null) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayShowTitleEnabled(false);
        }
    }
}
 
Example 3
Source File: TabFragment.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
@CallSuper
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_base, container, false);
    //Осторожно! Чувствительно к структуре разметки! (по идеи так должно работать чуть быстрее)
    fragmentContainer = (RelativeLayout) findViewById(R.id.fragment_container);
    coordinatorLayout = (CoordinatorLayout) fragmentContainer.findViewById(R.id.coordinator_layout);
    appBarLayout = (AppBarLayout) coordinatorLayout.findViewById(R.id.appbar_layout);
    toolbarLayout = (CollapsingToolbarLayout) appBarLayout.findViewById(R.id.toolbar_layout);
    toolbarBackground = (ImageView) toolbarLayout.findViewById(R.id.toolbar_image_background);
    toolbar = (Toolbar) toolbarLayout.findViewById(R.id.toolbar);
    toolbarImageView = (ImageView) toolbar.findViewById(R.id.toolbar_image_icon);
    toolbarTitleView = (TextView) toolbar.findViewById(R.id.toolbar_title);
    toolbarSubtitleView = (TextView) toolbar.findViewById(R.id.toolbar_subtitle);
    toolbarProgress = (ProgressBar) toolbar.findViewById(R.id.toolbar_progress);
    titlesWrapper = (LinearLayout) toolbar.findViewById(R.id.toolbar_titles_wrapper);
    toolbarSpinner = (Spinner) toolbar.findViewById(R.id.toolbar_spinner);
    notifyDot = findViewById(R.id.notify_dot);
    fragmentContent = (ViewGroup) coordinatorLayout.findViewById(R.id.fragment_content);
    additionalContent = (ViewGroup) coordinatorLayout.findViewById(R.id.additional_content);
    contentProgress = (ProgressBar) additionalContent.findViewById(R.id.content_progress);
    noNetwork = (LinearLayout) coordinatorLayout.findViewById(R.id.no_network);
    //// TODO: 20.03.17 удалить и юзать только там, где нужно
    fab = (FloatingActionButton) coordinatorLayout.findViewById(R.id.fab);
    contentController = new ContentController(contentProgress, additionalContent, fragmentContent);
    return view;
}
 
Example 4
Source File: BaseActivity.java    From Learning-Resources with MIT License 5 votes vote down vote up
/**
 * Center the Toolbar Title.
 *
 * @param toolbar
 */
protected void centerTitle(Toolbar toolbar) {
    final CharSequence originalTitle = toolbar.getTitle();
    TextView mTitle = toolbar.findViewById(R.id.toolbarTitle);
    mTitle.setText(originalTitle);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    toolbar.setTitle("");
}
 
Example 5
Source File: AbsBaseActivity.java    From LLApp with Apache License 2.0 5 votes vote down vote up
private void initToolBar() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setBackgroundColor(StaticValue.color);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        abTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
    }
    if (abTitle != null) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayShowTitleEnabled(false);
        }
    }
}
 
Example 6
Source File: ToolBarUtil.java    From Android-Architecture with Apache License 2.0 5 votes vote down vote up
/**
 * 设置Toolbar的标题
 *
 * @param toolbar
 * @param title
 */
public static void setToolBarTitle(Toolbar toolbar, CharSequence title) {
    if (toolbar == null) return;
    TextView titleView = (TextView) toolbar.findViewById(R.id.toolbar_title);
    if (titleView == null) return;
    titleView.setText(title);
}
 
Example 7
Source File: ToolBarUtil.java    From Android-Architecture with Apache License 2.0 5 votes vote down vote up
/**
 * 设置Toolbar的标题
 *
 * @param toolbar
 * @param resId
 */
public static void setToolBarTitle(Toolbar toolbar, int resId) {
    if (toolbar == null) return;
    TextView titleView = (TextView) toolbar.findViewById(R.id.toolbar_title);
    if (titleView == null) return;
    titleView.setText(resId);
}
 
Example 8
Source File: NewActivity.java    From Android-Carbon-Forum with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mTitle = (EditText) findViewById(R.id.title);
    mTag = (EditText) findViewById(R.id.tag);
    mContent = (EditText) findViewById(R.id.content);
    if (mToolbar != null) {
        mToolbar.setTitle(R.string.title_activity_new);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        ImageButton imageButton = (ImageButton) mToolbar.findViewById(R.id.new_button);
        imageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(mTitle.getText().toString().length() > 0 &&
                        mTag.getText().toString().replace(",",",").split(",").length > 0) {
                    MarkdownProcessor mMarkdownProcessor = new MarkdownProcessor();
                    String contentHTML = mMarkdownProcessor.markdown(mContent.getText().toString());
                    Intent intent = new Intent(NewActivity.this, NewService.class);
                    intent.putExtra("Title", mTitle.getText().toString());
                    intent.putExtra("Tag", mTag.getText().toString());
                    intent.putExtra("Content", contentHTML);
                    startService(intent);
                    onBackPressed();
                }else{
                    Snackbar.make(view, getString(R.string.content_empty), Snackbar.LENGTH_LONG)
                            .setAction("Action", null).show();
                }
            }
        });
    }
}
 
Example 9
Source File: CategorySelectionActivity.java    From CoolSignIn with Apache License 2.0 5 votes vote down vote up
public void setUpToolbar(User user) {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_player);
    setSupportActionBar(toolbar);
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    final AvatarView avatarView = (AvatarView) toolbar.findViewById(R.id.avatar);
    avatarView.setAvatar(user.getAvatar().getDrawableId());
    //noinspection PrivateResource
    ((TextView) toolbar.findViewById(R.id.title)).setText(getDisplayName());
}
 
Example 10
Source File: NotificationsActivity.java    From Android-Carbon-Forum with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notifications);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    ImageButton imageButton = (ImageButton) toolbar.findViewById(R.id.notifications_settings_button);
    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(NotificationsActivity.this, SettingsActivity.class);
            intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.NotificationPreferenceFragment.class.getName());
            intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
            startActivity(intent);
        }
    });
}
 
Example 11
Source File: BaseActivity.java    From Taxi-App-Android-XML with GNU General Public License v3.0 5 votes vote down vote up
public void setTitleHome(int toolbarId,int image, int btnDrawable, int imageTitle){
    Toolbar toolbar = (Toolbar) findViewById(toolbarId);
    setSupportActionBar(toolbar);
    ImageView pageTitle = (ImageView) toolbar.findViewById(image);
    pageTitle.setImageResource(imageTitle);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(btnDrawable);
    getSupportActionBar().setTitle("");
}
 
Example 12
Source File: BaseActivity.java    From Taxi-App-Android-XML with GNU General Public License v3.0 5 votes vote down vote up
public void setTitle(int toolbarId,int titleId, String title, int btnDrawable, int colorBg, int titleColor){
    Toolbar toolbar = (Toolbar) findViewById(toolbarId);
    toolbar.setBackgroundResource(colorBg);
    setSupportActionBar(toolbar);
    TextView pageTitle = (TextView) toolbar.findViewById(titleId);
    pageTitle.setText(title);
    pageTitle.setTextColor(getResources().getColor(titleColor));
    getSupportActionBar().setTitle("");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(btnDrawable);
}
 
Example 13
Source File: AppDetailsFragment.java    From android-permission-checker-app with Apache License 2.0 5 votes vote down vote up
private void setUpToolBar() {
  Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
  toolbar.setTitle("");
  TextView titleTextView = toolbar.findViewById(R.id.toolbar_title);
  titleTextView.setText("App Details");
  ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
  ActionBar supportActionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
  supportActionBar.setDisplayHomeAsUpEnabled(true);
  supportActionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white);
}
 
Example 14
Source File: PermissionListFragment.java    From android-permission-checker-app with Apache License 2.0 5 votes vote down vote up
private void setUpToolBar() {
  Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
  TextView titleTextView = toolbar.findViewById(R.id.toolbar_title);
  titleTextView.setText("Permission Groups");
  toolbar.setTitle("");
  ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
  ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
 
Example 15
Source File: BaseActivity.java    From demo-firebase-android with The Unlicense 5 votes vote down vote up
protected final void initToolbar(Toolbar toolbar, String titlePage) {
    this.toolbar = toolbar;
    this.tvToolbarTitle = toolbar.findViewById(R.id.tvToolbarTitle);
    this.ibToolbarBack = toolbar.findViewById(R.id.ibToolbarBack);
    this.ibToolbarHamburger = toolbar.findViewById(R.id.ibToolbarHamburger);

    setSupportActionBar(toolbar);

    tvToolbarTitle.setText(titlePage);

    if (getSupportActionBar() != null)
        getSupportActionBar().setTitle("");
}
 
Example 16
Source File: MobileActivity.java    From BluetoothCameraAndroid with MIT License 5 votes vote down vote up
@Override
public void initViews() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    CTextView cTextView = (CTextView) toolbar.findViewById(R.id.toolbar_textview);
    cTextView.setText("Devices");
    toolbar.setNavigationIcon(R.drawable.back);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    mDevicesListView = (ListView) findViewById(R.id.activity_mobile_device_list);
    mDevicesListView.setOnItemClickListener(this);

    findViewById(R.id.inapp_enable).setOnClickListener(this);
    findViewById(R.id.activity_mobile_new_device).setOnClickListener(this);
}
 
Example 17
Source File: BaseSearchActivity.java    From Pioneer with Apache License 2.0 4 votes vote down vote up
protected SearchView setupToolbar(Toolbar toolbar) {
    this.toolbar = toolbar;
    Navigator.setupToolbarNavigation(this, toolbar);
    toolbar.inflateMenu(R.menu.search_view);
    return (SearchView) toolbar.findViewById(R.id.action_search);
}
 
Example 18
Source File: InternalNoteActivity.java    From faveo-helpdesk-android-app with Open Software License 3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_internal_note);
    overridePendingTransition(R.anim.slide_in_from_right,R.anim.slide_in_from_right);
    Window window = InternalNoteActivity.this.getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(ContextCompat.getColor(InternalNoteActivity.this,R.color.faveo));
    toolbar= (Toolbar) findViewById(R.id.toolbarForInternalNote);
    imageView= (ImageView) toolbar.findViewById(R.id.imageViewBackTicketInternalNote);
    editTextInternalNote = (EditText) findViewById(R.id.editText_internal_note);
    buttonCreate = (Button) findViewById(R.id.button_create);
    ticketID= Prefs.getString("TICKETid",null);
    progressDialog=new ProgressDialog(this);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    buttonCreate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String note = editTextInternalNote.getText().toString();
            if (note.trim().length() == 0) {
                Toasty.warning(InternalNoteActivity.this, getString(R.string.msg_must_not_be_empty), Toast.LENGTH_LONG).show();
                return;
            }
            String userID = Prefs.getString("ID", null);
            if (userID != null && userID.length() != 0) {
                try {
                    note = URLEncoder.encode(note, "utf-8");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

                new CreateInternalNoteForTicket(Integer.parseInt(ticketID), Integer.parseInt(userID), note).execute();
                progressDialog.setMessage(getString(R.string.creating_note));
                progressDialog.show();


            } else
                Toasty.warning(InternalNoteActivity.this, getString(R.string.wrong_user_id), Toast.LENGTH_LONG).show();
        }
    });
    }
 
Example 19
Source File: ClientDetailActivity.java    From faveo-helpdesk-android-app with Open Software License 3.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_client_profile);
        Window window = ClientDetailActivity.this.getWindow();

        // clear FLAG_TRANSLUCENT_STATUS flag:
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

// finally change the color
        window.setStatusBarColor(ContextCompat.getColor(ClientDetailActivity.this,R.color.faveo));
        ButterKnife.bind(this);
        Constants.URL = Prefs.getString("COMPANY_URL", "");
        Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
//        if (getSupportActionBar() != null) {
//            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//            getSupportActionBar().setDisplayShowHomeEnabled(true);
//            getSupportActionBar().setDisplayShowTitleEnabled(false);
//        }
        TextView mTitle = (TextView) mToolbar.findViewById(R.id.title);
        mTitle.setText(R.string.profile);
        imageViewBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        setUpViews();
        Intent intent = getIntent();
        clientID = intent.getStringExtra("CLIENT_ID");

        if (InternetReceiver.isConnected()) {
            progressDialog.show();
            task = new FetchClientTickets(ClientDetailActivity.this);
            task.execute();


        } else Toasty.warning(this, getString(R.string.oops_no_internet), Toast.LENGTH_LONG).show();

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
        setupViewPager();
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setOnTabSelectedListener(onTabSelectedListener);

    }
 
Example 20
Source File: BaseSearchActivity.java    From Pioneer with Apache License 2.0 4 votes vote down vote up
protected SearchView setupToolbar(Toolbar toolbar) {
    this.toolbar = toolbar;
    Navigator.setupToolbarNavigation(this, toolbar);
    toolbar.inflateMenu(R.menu.search_view);
    return (SearchView) toolbar.findViewById(R.id.action_search);
}