本文整理了Java中android.support.v7.widget.Toolbar.<init>()
方法的一些代码示例,展示了Toolbar.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.<init>()
方法的具体详情如下:
包路径:android.support.v7.widget.Toolbar
类名称:Toolbar
方法名:<init>
暂无
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toolbar toolbar = new Toolbar(this);
toolbar.setTitle(R.string.activity_service_list_title);
toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
toolbar.setBackgroundColor(Color.parseColor("#00a0e9"));
addContentView(toolbar, new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
toolbar.setNavigationIcon(R.drawable.close_icon);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
LinearLayout layout = (LinearLayout) findViewById(R.id.fragment_container);
final TypedArray styledAttributes = getTheme().obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
int actionBarSize = (int) styledAttributes.getDimension(0, 0);
layout.setPadding(0, actionBarSize, 0, 0);
}
代码示例来源:origin: denzilferreira/aware-client
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, final Preference preference) {
if (preference instanceof PreferenceScreen) {
Dialog subpref = ((PreferenceScreen) preference).getDialog();
ViewGroup root = (ViewGroup) subpref.findViewById(android.R.id.content).getParent();
Toolbar toolbar = new Toolbar(this);
toolbar.setBackgroundColor(ContextCompat.getColor(preferenceScreen.getContext(), R.color.primary));
toolbar.setTitleTextColor(ContextCompat.getColor(preferenceScreen.getContext(), android.R.color.white));
toolbar.setTitle(preference.getTitle());
root.addView(toolbar, 0); //add to the top
subpref.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
new SettingsSync().execute(preference);
}
});
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* ViewPagerを持つレイアウトを自動的に設定する.
* サブクラスでオーバーライドする場合は setContentView を<strong>実行しないこと</strong>。
*
* @param savedInstanceState パラメータ
* @see android.app.Activity#onCreate(Bundle)
*/
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_page);
mViewPager = (ViewPager) findViewById(R.id.setting_pager);
mViewPager.setAdapter(new DConnectFragmentPagerAdapter(getSupportFragmentManager(), this));
Toolbar toolbar = new Toolbar(this);
toolbar.setTitle(org.deviceconnect.android.deviceplugin.chromecast.R.string.activity_setting_page_title);
toolbar.setBackgroundColor(Color.parseColor("#00a0e9"));
toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
addContentView(toolbar, new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
toolbar.setNavigationIcon(org.deviceconnect.android.deviceplugin.chromecast.R.drawable.close_icon);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
setSupportActionBar(toolbar);
}
代码示例来源:origin: hamidness/restring
@Test
public void shouldTransformToolbar() {
Context context = getContext();
View view = transformer.transform(new Toolbar(context), getAttributeSet(false));
assertTrue(view instanceof Toolbar);
assertEquals(((Toolbar) view).getTitle(), TITLE_ATTR_VALUE);
view = transformer.transform(new Toolbar(context), getAttributeSet(true));
assertTrue(view instanceof Toolbar);
assertEquals(((Toolbar) view).getTitle(), TITLE_ATTR_VALUE);
}
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
static Toolbar getSelectorModeToolbar(Context context,
View.OnClickListener onClickListener,
Toolbar.OnMenuItemClickListener onItemClickListener) {
final Toolbar toolbar = new Toolbar(context);
toolbar.setTag(SELECTOR_TOOLBAR_TAG);
内容来源于网络,如有侵权,请联系作者删除!