androidx.appcompat.app.ActionBar#getCustomView ( )源码实例Demo

下面列出了androidx.appcompat.app.ActionBar#getCustomView ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FairEmail   文件: FragmentBase.java
private void updateSubtitle() {
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    if (activity != null && !isPane()) {
        ActionBar actionbar = activity.getSupportActionBar();
        if (actionbar != null)
            if ((actionbar.getDisplayOptions() & DISPLAY_SHOW_CUSTOM) == 0) {
                actionbar.setTitle(title == null ? getString(R.string.app_name) : title);
                actionbar.setSubtitle(subtitle);
            } else {
                View custom = actionbar.getCustomView();
                TextView tvTitle = custom.findViewById(R.id.title);
                TextView tvSubtitle = custom.findViewById(R.id.subtitle);
                tvTitle.setText(title == null ? getString(R.string.app_name) : title);
                tvSubtitle.setText(subtitle);
            }
    }
}
 
源代码2 项目: deltachat-android   文件: ProfileActivity.java
@Override
protected void onCreate(Bundle bundle, boolean ready) {
  setContentView(R.layout.profile_activity);

  initializeResources();

  setSupportActionBar(this.toolbar);
  ActionBar supportActionBar = getSupportActionBar();
  supportActionBar.setDisplayHomeAsUpEnabled(false);
  supportActionBar.setCustomView(R.layout.conversation_title_view);
  supportActionBar.setDisplayShowCustomEnabled(true);
  supportActionBar.setDisplayShowTitleEnabled(false);
  Toolbar parent = (Toolbar) supportActionBar.getCustomView().getParent();
  parent.setPadding(0,0,0,0);
  parent.setContentInsetsAbsolute(0,0);

  titleView = (ConversationTitleView) supportActionBar.getCustomView();
  titleView.setOnBackClickedListener(view -> onBackPressed());
  titleView.setOnClickListener(view -> onEnlargeAvatar());

  updateToolbar();

  this.tabLayout.setupWithViewPager(viewPager);
  this.viewPager.setAdapter(new ProfilePagerAdapter(getSupportFragmentManager()));
  dcContext.eventCenter.addObserver(DcContext.DC_EVENT_CHAT_MODIFIED, this);
  dcContext.eventCenter.addObserver(DcContext.DC_EVENT_CONTACTS_CHANGED, this);
}
 
源代码3 项目: shortyz   文件: HoneycombUtil.java
public View onActionBarCustom(AppCompatActivity a, int id) {
   	ActionBar bar = a.getSupportActionBar();
   	if(bar == null){
   		return null;
   	}
   	bar.setDisplayShowCustomEnabled(true);
   	bar.setDisplayShowTitleEnabled(false);
   	bar.setDisplayShowHomeEnabled(true);
   	bar.setCustomView(id);
   	return bar.getCustomView();
}
 
源代码4 项目: shortyz   文件: GingerbreadUtil.java
public View onActionBarCustom(AppCompatActivity a, int id) {
    System.out.println("Setting custom ActionBar view");
    ActionBar bar = a.getSupportActionBar();
    if(bar == null){
        return null;
    }
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setDisplayShowHomeEnabled(true);
    bar.setCustomView(id);
    return bar.getCustomView();
}
 
源代码5 项目: deltachat-android   文件: ConversationActivity.java
private void initializeViews() {
  ActionBar supportActionBar = getSupportActionBar();
  if (supportActionBar == null) throw new AssertionError();

  titleView             = (ConversationTitleView) supportActionBar.getCustomView();
  buttonToggle          = ViewUtil.findById(this, R.id.button_toggle);
  sendButton            = ViewUtil.findById(this, R.id.send_button);
  attachButton          = ViewUtil.findById(this, R.id.attach_button);
  composeText           = ViewUtil.findById(this, R.id.embedded_text_editor);
  emojiDrawerStub       = ViewUtil.findStubById(this, R.id.emoji_drawer_stub);
  composePanel          = ViewUtil.findById(this, R.id.bottom_panel);
  container             = ViewUtil.findById(this, R.id.layout_container);
  reminderView          = ViewUtil.findStubById(this, R.id.reminder_stub);
  quickAttachmentDrawer = ViewUtil.findById(this, R.id.quick_attachment_drawer);
  quickAttachmentToggle = ViewUtil.findById(this, R.id.quick_attachment_toggle);
  inputPanel            = ViewUtil.findById(this, R.id.bottom_panel);

  ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle);

  container.addOnKeyboardShownListener(this);
  inputPanel.setListener(this);
  inputPanel.setMediaListener(this);

  attachmentTypeSelector = null;
  attachmentManager      = new AttachmentManager(this, this);
  audioRecorder          = new AudioRecorder(this);

  SendButtonListener        sendButtonListener        = new SendButtonListener();
  ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();

  composeText.setOnEditorActionListener(sendButtonListener);
  attachButton.setOnClickListener(new AttachButtonListener());
  attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
  sendButton.setOnClickListener(sendButtonListener);
  sendButton.setEnabled(true);
  sendButton.addOnTransportChangedListener((newTransport, manuallySelected) -> {
    composeText.setTransport(newTransport);
    buttonToggle.getBackground().invalidateSelf();
  });

  titleView.setOnClickListener(v -> handleProfile());
  titleView.setOnBackClickedListener(view -> onBackPressed());

  composeText.setOnKeyListener(composeKeyPressedListener);
  composeText.addTextChangedListener(composeKeyPressedListener);
  composeText.setOnEditorActionListener(sendButtonListener);
  composeText.setOnClickListener(composeKeyPressedListener);
  composeText.setOnFocusChangeListener(composeKeyPressedListener);

  if (QuickAttachmentDrawer.isDeviceSupported(this)) {
    quickAttachmentDrawer.setListener(this);
    quickCameraToggle.setOnClickListener(new QuickCameraToggleListener());
  } else {
    quickCameraToggle.setVisibility(View.GONE);
    quickCameraToggle.setEnabled(false);
  }

  initializeBackground();
}