本文整理汇总了Java中android.support.v7.widget.Toolbar.setBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:Java Toolbar.setBackgroundResource方法的具体用法?Java Toolbar.setBackgroundResource怎么用?Java Toolbar.setBackgroundResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.Toolbar
的用法示例。
在下文中一共展示了Toolbar.setBackgroundResource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_response);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(true);
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
restTest = (RestTest) getIntent().getSerializableExtra("restTest");
response = (RemoteResponse) getIntent().getSerializableExtra("response");
mViewPager = (AdvancedViewPager) findViewById(R.id.container);
mViewPager.setEnable(false);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
int code = response.getStatusCode();
if (code >= 200 && code <= 299) {
toolbar.setBackgroundResource(R.color.get);
tabLayout.setBackgroundResource(R.color.get);
} else {
toolbar.setBackgroundResource(R.color.error);
tabLayout.setBackgroundResource(R.color.error);
}
if (-1 == response.getStatusCode()) {
ab.setTitle(response.getResponseMessage());
} else {
ab.setTitle(response.getStatusCode() + " " + response.getResponseMessage());
}
}
示例2: setTitle
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
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);
}
示例3: initView
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override protected void initView(View parent) {
requestBaseInit(getPageTitle());
mRecyclerView = (RecyclerView) parent.findViewById(R.id.recyclerView);
Toolbar toolbar = getToolBar();
toolbar.inflateMenu(R.menu.main);
toolbar.setBackgroundResource(R.color.main_color_normal);
toolbar.setOnMenuItemClickListener(this);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecyclerView.setHasFixedSize(true);
setupAdapter();
}
示例4: requestBaseInit
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
protected void requestBaseInit(String title) {
TranslucentStatusCompat.requestTranslucentStatus(getActivity());
getToolBarShadow().setVisibility(View.GONE);
Toolbar toolBar = getToolBar();
getStatusBar().setBackgroundResource(R.color.main_color_normal);
toolBar.setBackgroundResource(R.color.main_color_normal);
TextView tvTitle = UIUtil.setCenterTitle(toolBar, title);
CommonUtils.updateTitleText(tvTitle);
toolBar.setNavigationIcon(R.drawable.ic_back);
toolBar.setNavigationOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
getActivity().onBackPressed();
}
});
}
示例5: requestBaseInitNoBack
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
protected void requestBaseInitNoBack(String title) {
TranslucentStatusCompat.requestTranslucentStatus(getActivity());
getToolBarShadow().setVisibility(View.GONE);
Toolbar toolBar = getToolBar();
getStatusBar().setBackgroundResource(R.color.main_color_normal);
toolBar.setBackgroundResource(R.color.main_color_normal);
TextView tvTitle = UIUtil.setCenterTitle(toolBar, title);
CommonUtils.updateTitleText(tvTitle);
}