android.support.v7.widget.Toolbar#findViewById ( )源码实例Demo

下面列出了android.support.v7.widget.Toolbar#findViewById ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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);
        }
    });
}
 
源代码2 项目: BluetoothCameraAndroid   文件: MobileActivity.java
@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);
}
 
源代码3 项目: demo-firebase-android   文件: BaseActivity.java
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("");
}
 
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);
}
 
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);
}
 
源代码6 项目: Taxi-App-Android-XML   文件: BaseActivity.java
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);
}
 
源代码7 项目: Taxi-App-Android-XML   文件: BaseActivity.java
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("");
}
 
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("");
}
 
源代码9 项目: CoolSignIn   文件: CategorySelectionActivity.java
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());
}
 
源代码10 项目: Android-Carbon-Forum   文件: NewActivity.java
@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();
                }
            }
        });
    }
}
 
源代码11 项目: Android-Architecture   文件: ToolBarUtil.java
/**
 * 设置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);
}
 
源代码12 项目: Android-Architecture   文件: ToolBarUtil.java
/**
 * 设置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);
}
 
源代码13 项目: LLApp   文件: AbsBaseActivity.java
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);
        }
    }
}
 
源代码14 项目: Learning-Resources   文件: BaseActivity.java
/**
 * 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("");
}
 
源代码15 项目: ForPDA   文件: TabFragment.java
@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;
}
 
源代码16 项目: LLApp   文件: AbsBaseSwipeBackActivity.java
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);
        }
    }
}
 
源代码17 项目: Pioneer   文件: BaseSearchActivity.java
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);
}
 
@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);

    }
 
源代码19 项目: Pioneer   文件: BaseSearchActivity.java
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);
}
 
@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();
        }
    });
    }