當前位置: 首頁>>代碼示例>>Java>>正文


Java Toolbar類代碼示例

本文整理匯總了Java中android.support.v7.widget.Toolbar的典型用法代碼示例。如果您正苦於以下問題:Java Toolbar類的具體用法?Java Toolbar怎麽用?Java Toolbar使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Toolbar類屬於android.support.v7.widget包,在下文中一共展示了Toolbar類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initToolbar

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
private void initToolbar() {
    Toolbar toolbar = findViewById(R.id.actionBarChat);
    toolbar.setTitleTextColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white));
    toolbar.setTitle(cname);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_left);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    if (ctype != Chat.ChatType.PRIVATE && Utils.getController().getMessengerDatabase().userInChat(Utils.getUserID(), cid)) {
        toolbar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(getApplicationContext(), ChatEditActivity.class)
                        .putExtra("cid", cid)
                        .putExtra("cname", cname), 1);
            }
        });
    }
}
 
開發者ID:LCA311,項目名稱:leoapp-sources,代碼行數:20,代碼來源:ChatActivity.java

示例2: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_music);

    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setNavigationIcon(R.drawable.back);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    setupListView((ListView) findViewById(R.id.listView));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:MusicActivity.java

示例3: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_practice_profile);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    //狀態欄透明和間距處理
    StatusBarUtil.immersive(this);
    StatusBarUtil.setPaddingSmart(this, toolbar);
    StatusBarUtil.setPaddingSmart(this, findViewById(R.id.profile));
    StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurview));
}
 
開發者ID:scwang90,項目名稱:SmartRefreshLayout,代碼行數:20,代碼來源:ProfilePracticeActivity.java

示例4: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_horario);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
        getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
    }
    app = (App) getApplication();
    if (app.account == null && !app.loadUser()) //If account is null and cannot create user
        super.onDestroy();
    mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView = (RecyclerView) findViewById(R.id.horarioRecycler);
    emptyView = (LinearLayout) findViewById(R.id.horario_blank);
    recyclerView.setLayoutManager(mLayoutManager);

    initializePicker();
    getDateData(new Date());
}
 
開發者ID:Onelio,項目名稱:ConnectU,代碼行數:26,代碼來源:HorarioActivity.java

示例5: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_finalizadas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_cf);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCF);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_cf));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Mis changas finalizadas");
    }

}
 
開發者ID:sloiza,項目名稱:changApp,代碼行數:21,代碼來源:ChangasFinalizadasActivity.java

示例6: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_timeline);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if(getSupportActionBar()!=null)
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mOrientation = (Orientation) getIntent().getSerializableExtra(MainActivity.EXTRA_ORIENTATION);
    mWithLinePadding = getIntent().getBooleanExtra(MainActivity.EXTRA_WITH_LINE_PADDING, false);

    setTitle(mOrientation == Orientation.HORIZONTAL ? getResources().getString(R.string.horizontal_timeline) : getResources().getString(R.string.vertical_timeline));

    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    mRecyclerView.setLayoutManager(getLinearLayoutManager());
    mRecyclerView.setHasFixedSize(true);

    initView();
}
 
開發者ID:open-android,項目名稱:Timeline,代碼行數:23,代碼來源:TimeLineActivity.java

示例7: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        ActivitySectionDetailsBinding binding = DataBindingUtil.setContentView (this, R.layout.activity_section_details);
        mSectionIndex = getIntent ().getIntExtra (GlobalData.SECTION_INDEX, 1); //TODO do has extra
        Toolbar toolbar = (Toolbar) findViewById (R.id.toolbarSubDetail);
        setSupportActionBar (toolbar);
        android.support.v7.app.ActionBar actionBar = getSupportActionBar ();
        Button updateButton = (Button) findViewById (R.id.update);
        mSectionNameEditText = (EditText) findViewById (R.id.textViewSectionName);
        mSectionDescriptionEditText = (EditText) findViewById (R.id.textViewDescriptionName);
        updateButton.setOnClickListener (this);
//        Toast.makeText (SectionDetailsActivity.this, "file id ="+getIntent ().getLongExtra (GlobalData.SECTION_INDEX,-1), Toast.LENGTH_LONG).show ();
        mSubject = new SectionDetailsBinder (SectionDetailsActivity.this, mSectionIndex + 1);
        mSubject.setInputType ("none");
        binding.setSubject (mSubject);
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled (true);
        }
    }
 
開發者ID:atulgpt,項目名稱:TimeTrix,代碼行數:21,代碼來源:SectionDetailsActivity.java

示例8: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  FloatingActionButton fab = findViewById(R.id.fab);
  fab.setOnClickListener(
      view -> Snackbar.make(view, "Want to set email ?", Snackbar.LENGTH_LONG)
          .setAction("Action", null).show());
  DrawerLayout drawer = findViewById(R.id.drawer_layout);
  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  drawer.addDrawerListener(toggle);
  toggle.syncState();
  NavigationView navigationView = findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);
}
 
開發者ID:charlesng,項目名稱:SampleAppArch,代碼行數:18,代碼來源:AppArchNavigationDrawer.java

示例9: onCreateView

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_energy_use_bill, container, false);
    this.radioButtonFromDate = (RadioButton) view.findViewById(R.id.radioButtonFromDate);
    this.radioButtonToDate = (RadioButton) view.findViewById(R.id.radioButtonToDate);
    this.editKwhCost = (EditText) view.findViewById(R.id.editKwhCost);
    this.datePicker = (DatePicker) view.findViewById(R.id.datePicker);
    this.toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    this.setTextRadioButtonDate(radioButtonFromDate, this.fromDate);
    this.setTextRadioButtonDate(radioButtonToDate, this.toDate);
    this.setCalendarView();
    this.editKwhCost.setText(OhaHelper.getEditable(this.kwhCost));
    this.radioButtonFromDate.setOnClickListener(this);
    this.radioButtonToDate.setOnClickListener(this);
    this.datePicker.setOnClickListener(this);
    //Remover o date_picker_header do datePicker se o mesmo existir
    View viewDayDatePicker = datePicker.findViewById(Resources.getSystem().getIdentifier("date_picker_header", "id", "android"));
    if (viewDayDatePicker != null) {
        viewDayDatePicker.setVisibility(View.GONE);
    }
    this.toolbar.inflateMenu(R.menu.fragment_energy_use_bill);
    this.toolbar.setOnMenuItemClickListener(this);
    return view;
}
 
開發者ID:brolam,項目名稱:OpenHomeAnalysis,代碼行數:27,代碼來源:OhaEnergyUseBillFragment.java

示例10: setupAppBar

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
    setStatusBarColor(mStatusBarColor);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    // Set all of the Toolbar coloring
    toolbar.setBackgroundColor(mToolbarColor);
    toolbar.setTitleTextColor(mToolbarWidgetColor);

    final TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
    toolbarTitle.setTextColor(mToolbarWidgetColor);
    toolbarTitle.setText(mToolbarTitle);

    // Color buttons inside the Toolbar
    Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate();
    stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationIcon(stateButtonDrawable);

    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
}
 
開發者ID:Alcatraz323,項目名稱:MaterialOCR,代碼行數:28,代碼來源:UCropActivity.java

示例11: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);
    viewPager.setOffscreenPageLimit(ITEM_COUNT);

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

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Config.REGISTRATION_COMPLETE)) {
                FirebaseMessaging.getInstance().subscribeToTopic(Config.TOPIC_GLOBAL);
            } else if (intent.getAction().equals(Config.PUSH_NOTIFICATION)) {
                // new push notification is received
            }
        }
    };
}
 
開發者ID:anandwana001,項目名稱:Tech-Jalsa,代碼行數:27,代碼來源:MainActivity.java

示例12: getNavigationMenuItem

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
/**
 * Returns the menu item, which shows the navigation icon of the tab switcher's toolbar.
 *
 * @return The menu item, which shows the navigation icon of the tab switcher's toolbar, as an
 * instance of the class {@link View} or null, if no navigation icon is shown
 */
@Nullable
private View getNavigationMenuItem() {
    Toolbar[] toolbars = tabSwitcher.getToolbars();

    if (toolbars != null) {
        Toolbar toolbar = toolbars.length > 1 ? toolbars[1] : toolbars[0];
        int size = toolbar.getChildCount();

        for (int i = 0; i < size; i++) {
            View child = toolbar.getChildAt(i);

            if (child instanceof ImageButton) {
                return child;
            }
        }
    }

    return null;
}
 
開發者ID:michael-rapp,項目名稱:ChromeLikeTabSwitcher,代碼行數:26,代碼來源:MainActivity.java

示例13: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Well done Paolo! Thanks too Dom and Mihchele", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
 
開發者ID:Francescopaolo44,項目名稱:AndroidApp-Deploy,代碼行數:27,代碼來源:MainActivity.java

示例14: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_menu);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final 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 action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
    );

    drawer.addDrawerListener(toggle);
    toggle.syncState();
    drawer.openDrawer(Gravity.START);
}
 
開發者ID:PacktPublishing,項目名稱:Hands-On-Android-UI-Development,代碼行數:26,代碼來源:NavigationMenuActivity.java

示例15: onCreate

import android.support.v7.widget.Toolbar; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_result);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    scoreLabel = (TextView) findViewById(R.id.scoreLabel);
    highScoreLabel = (TextView) findViewById(R.id.highScoreLabel);

    score = getIntent().getIntExtra(getString(R.string.score), 0);
    scoreLabel.setText(score + "");

    SharedPreferences settings = getSharedPreferences(getString(R.string.high_score), Context.MODE_PRIVATE);
    int highScore = settings.getInt(getString(R.string.high_score), 0);

    if (score > highScore) {
        highScoreLabel.setText(getString(R.string.high_score) + score);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(getString(R.string.high_score), score);
        editor.commit();
    } else {
        highScoreLabel.setText(getString(R.string.high_score) + highScore);
    }
}
 
開發者ID:anandwana001,項目名稱:Tech-Jalsa,代碼行數:26,代碼來源:result.java


注:本文中的android.support.v7.widget.Toolbar類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。