android.support.v7.widget.Toolbar Java Examples

The following examples show how to use android.support.v7.widget.Toolbar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingsActivity.java    From sharelock-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    Toolbar toolbar = (Toolbar) findViewById(R.id.sharelock_toolbar);
    setSupportActionBar(toolbar);
    setTitle(null);
    endpointEditText = (TextView) findViewById(R.id.settings_endpoint_url);
    final SharedPreferences preferences = getSharedPreferences(getPackageName(), MODE_PRIVATE);
    endpointEditText.setText(preferences.getString(LinkAPIClient.SHARELOCK_ENDPOINT_KEY, LinkAPIClient.DEFAULT_URL));
    Button resetButton = (Button) findViewById(R.id.settings_default_button);
    resetButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            endpointEditText.setText(LinkAPIClient.DEFAULT_URL);
        }
    });
}
 
Example #2
Source File: AtUserActivity.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.at_user_activity_layout);

    Toolbar mAtUserToolBar = (Toolbar) findViewById(R.id.atUserToolbar);

    String token = getIntent().getStringExtra(TOKEN_HACK);
    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .replace(R.id.at_content_frame, new AtUserFragment(token, mAtUserToolBar)).commit();
    }

    disPlayHomeAsUp(mAtUserToolBar);
}
 
Example #3
Source File: Playground.java    From SuperToasts with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_playground);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    final Button button = (Button) findViewById(R.id.random);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            getRandomSuperToast().show();
        }
    });

    SuperActivityToast.onRestoreState(this, savedInstanceState,
            ListenerUtils.newInstance()
                    .putListener("good_tag_name", onButtonClickListener));
}
 
Example #4
Source File: ToolbarContentTintHelper.java    From APlayer with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) {
  if (ab == null || !(ab instanceof WindowDecorActionBar)) {
    return null;
  }
  try {
    WindowDecorActionBar decorAb = (WindowDecorActionBar) ab;
    Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar");
    field.setAccessible(true);
    ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb);
    field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar");
    field.setAccessible(true);
    return (Toolbar) field.get(wrapper);
  } catch (Throwable t) {
    throw new RuntimeException(
        "Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t);
  }
}
 
Example #5
Source File: MainActivity.java    From XModulable with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity_main);
    Toolbar toolbar = findViewById(R.id.main_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(false); // 设置导航按钮无效
    getSupportActionBar().setDisplayHomeAsUpEnabled(false); // 不显示导航按钮
    getSupportActionBar().setDisplayShowTitleEnabled(true); // 显示标题

    TabLayout tabLayout = findViewById(R.id.main_tab_layout);
    ViewPager viewPager = findViewById(R.id.main_pager);
    LinkedHashMap<String, Fragment> fragments = new LinkedHashMap<>(3);
    fragments.put("main", new MainFragment());
    if (liveModule != null) {
        fragments.put("live", liveModule.getLiveService().createLiveEntranceFragment());
    }
    if (imModule != null) {
        fragments.put("im", imModule.getIMService().createIMEntranceFragment());
    }
    viewPager.setAdapter(new MainPagerAdapter(getSupportFragmentManager(), fragments));
    tabLayout.setupWithViewPager(viewPager);
}
 
Example #6
Source File: StaticShortcutActivity.java    From journaldev with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_static_shortcut);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    TextView textView = findViewById(R.id.tvTitle);

    if (getIntent() != null && getIntent().getStringExtra("key") != null) {
        String bundleString = getIntent().getStringExtra("key");
        textView.setText(bundleString);
    }

    FloatingActionButton fab = 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();
        }
    });
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example #7
Source File: DemoCustomView02Activity.java    From RecyclerTabLayout with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo_custom_view02);

    Demo demo = Demo.valueOf(getIntent().getStringExtra(KEY_DEMO));

    Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle(demo.titleResId);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    DemoImagePagerAdapter adapter = new DemoImagePagerAdapter();
    adapter.addAll(DemoData.loadImageResourceList());

    ViewPager viewPager = findViewById(R.id.view_pager);
    viewPager.setAdapter(adapter);

    RecyclerTabLayout recyclerTabLayout = findViewById(R.id.recycler_tab_layout);
    recyclerTabLayout.setUpWithAdapter(new DemoCustomView02Adapter(viewPager));
    recyclerTabLayout.setPositionThreshold(0.5f);
}
 
Example #8
Source File: ChatGroupsListActivity.java    From chat21-android-sdk with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat_groups_list);

    contactsListFragment = new ChatGroupsListFragment();
    contactsListFragment.setOnChatGroupClickListener(this);

    // #### BEGIN TOOLBAR ####
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // #### END  TOOLBAR ####

    // #### BEGIN CONTAINER ####
    getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.container, contactsListFragment)
            .commit();
    // #### BEGIN CONTAINER ####
}
 
Example #9
Source File: SwipeableCard.java    From SwipeableCard with Apache License 2.0 6 votes vote down vote up
/**
 * Animation Card for up animation, please do not modify this.
 * @param card card view instance
 * @param toolbar toolbar instance
 */
@Override
public void animationCardUp(@NotNull final CardView card, @NotNull final Toolbar toolbar, final long duration){
    new CountDownTimer(1, 1) {
        public void onTick(long millisUntilFinished) {
        }

        public void onFinish() {
            card.animate()
                    .translationY(height - (card.getHeight() + toolbar.getHeight()))
                    .setDuration(duration).start();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                fab.animate()
                        .translationY((height - (card.getHeight() + toolbar.getHeight())) + card.getHeight() - (fab.getHeight() - fab.getHeight() / 4))
                        .setDuration(duration).start();
            }else {
                fab.animate()
                        .translationY((height - (card.getHeight() + toolbar.getHeight())) + card.getHeight() - (fab.getHeight() - fab.getHeight() / 3))
                        .setDuration(duration).start();
            }
        }
    }.start();
}
 
Example #10
Source File: SettingsActivity.java    From video-transcoder with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings_layout);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if(actionBar != null)
    {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    // Display the fragment as the main content.
    getFragmentManager().beginTransaction()
            .replace(R.id.fragment_container, new SettingsFragment())
            .commit();
}
 
Example #11
Source File: MainActivity.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

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

    mListView = (ListView) findViewById(R.id.list);

    mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new ArrayList<String>());

    mAdapter.add("Movie 1");
    mAdapter.add("Movie 2");
    mAdapter.add("Movie 3");
    mAdapter.add("Movie 4");
    mAdapter.add("Movie 5");
    mAdapter.add("Movie 6");
    mAdapter.add("Movie 7");

    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(this);

    CastContext.getSharedInstance(this).addCastStateListener(this);
    CastContext.getSharedInstance(this).addAppVisibilityListener(this);
    CastContext.getSharedInstance(this).getSessionManager().addSessionManagerListener(this);
}
 
Example #12
Source File: CreateActivity.java    From materialup with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create);

    ButterKnife.bind(this);
    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) {
            fabClick(view);
        }
    });
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example #13
Source File: AboutActivity.java    From MLManager with GNU General Public License v3.0 6 votes vote down vote up
private void setInitialConfiguration() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.action_about);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressed();
        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        getWindow().setStatusBarColor(UtilsUI.darker(appPreferences.getPrimaryColorPref(), 0.8));
        toolbar.setBackgroundColor(appPreferences.getPrimaryColorPref());
        if (!appPreferences.getNavigationBlackPref()) {
            getWindow().setNavigationBarColor(appPreferences.getPrimaryColorPref());
        }
    }

}
 
Example #14
Source File: MainActivity.java    From FirebaseMessagingApp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mLogoutPresenter = new LogoutPresenter(this);

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

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    setupTabIcons();
}
 
Example #15
Source File: AbstractSearchableListItemActivity.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	this.binding = DataBindingUtil.setContentView(this,R.layout.activity_choose_contact);
	setSupportActionBar((Toolbar) binding.toolbar);
	configureActionBar(getSupportActionBar());
	this.binding.chooseContactList.setFastScrollEnabled(true);
	mListItemsAdapter = new ListItemAdapter(this, listItems);
	this.binding.chooseContactList.setAdapter(mListItemsAdapter);
}
 
Example #16
Source File: IssuersActivity.java    From px-android with MIT License 5 votes vote down vote up
private void loadToolbarArrow(final Toolbar toolbar) {
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }
    if (toolbar != null) {
        toolbar.setNavigationOnClickListener(v -> onBackPressed());
    }
}
 
Example #17
Source File: FriendFacebookActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_friends_search);

    toolbar = (Toolbar) findViewById(R.id.toolbar1);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Find friends on Facebook");
    toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white));

    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);


    allList = new ArrayList<>();
    allAdapter = new FriendAdapter(context, allList);
    /*
    allAdapter.setClickListener(new FriendAdapter.ClickListener() {
        @Override
        public void onItemClickListener(View v, int pos) {

        }

        @Override
        public void onFriendListener(int pos, boolean isFollowing) {

        }
    });*/

    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setAdapter(allAdapter);

    setList();
}
 
Example #18
Source File: ManageAccountActivity.java    From wmn-safety with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle("Update Account");

    mNameInputEditText = findViewById(R.id.account_update_full_name);
    mEmailInputEditText = findViewById(R.id.account_update_email);
    mPhoneInputEditText = findViewById(R.id.account_update_phone);

    mFirebaseAuth = FirebaseAuth.getInstance();
    mFirebaseUser = mFirebaseAuth.getCurrentUser();
    mFirebaseDatabase = FirebaseDatabase.getInstance();
    mDatabaseReference = mFirebaseDatabase.getReference().child("users");

    mDatabaseReference.child(mFirebaseUser.getUid()).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            UserData userData = dataSnapshot.getValue(UserData.class);
            if(userData != null)  {
                mNameInputEditText.setText(userData.getName());
                mEmailInputEditText.setText(userData.getEmail());
                mPhoneInputEditText.setText(userData.getNumber());
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}
 
Example #19
Source File: MainActivity.java    From scroball with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  application = (ScroballApplication) getApplication();
  application.startListenerService();

  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  // 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 = findViewById(R.id.container);
  mViewPager.setAdapter(mSectionsPagerAdapter);

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

  // Initial tab may have been specified in the intent.
  int initialTab = getIntent().getIntExtra(EXTRA_INITIAL_TAB, TAB_NOW_PLAYING);
  mViewPager.setCurrentItem(initialTab);

  this.adsRemoved = application.getSharedPreferences().getBoolean(REMOVE_ADS_SKU, false);

  adView = findViewById(R.id.adView);
  if (this.adsRemoved) {
    RelativeLayout parent = (RelativeLayout) adView.getParent();
    if (parent != null) {
      parent.removeView(adView);
    }
  } else {
    AdRequest adRequest =
        new AdRequest.Builder().addTestDevice("86193DC9EBC8E1C3873178900C9FCCFC").build();
    adView.loadAd(adRequest);
  }
}
 
Example #20
Source File: MainActivity.java    From RefreshLoadMoreRecyclerView with MIT License 5 votes vote down vote up
/**
 * 初始化视图
 */
private void initViews() {
    mToolBar = (Toolbar) findViewById(R.id.id_toolbar);
    if (mToolBar != null)
        setSupportActionBar(mToolBar);
    mRecyclerView = (HarvestRecyclerView) findViewById(R.id.id_harvest_recyclerview);
    manager = new LinearLayoutManager(this);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(manager);
    mRecyclerView.setEmptyView(getResources().getDrawable(R.drawable.ic_results_empty), "No data Here.", new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            adapter.data.add("onRefresh" + refreshNum++);
            adapter.notifyDataSetChanged();
        }
    });
    onRefreshListener = new HarvestRecyclerView.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (refreshNum >= 8) {
                adapter.data.clear();
            } else
                adapter.data.add(0, "onRefresh" + refreshNum++);
            adapter.notifyDataSetChanged();
        }
    };
    onLoadMoreListener = new HarvestRecyclerView.OnLoadMoreListener() {
        @Override
        public void onLoadMore() {
            if (loadMoreNum >= 8) {
                mRecyclerView.setLoadMoreEnabled(false, null);
            } else
                adapter.data.add("onLoadMore" + loadMoreNum++);
            adapter.notifyDataSetChanged();
        }
    };
}
 
Example #21
Source File: MobileActivity.java    From BluetoothCameraAndroid with MIT License 5 votes vote down vote up
@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);
}
 
Example #22
Source File: WaterMarkPrefActivity.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.water_mark_setting_layout);
    Toolbar mWaterMarkToolbar = (Toolbar) findViewById(R.id.waterMarkToolbar);
    mWaterMarkToolbar.setTitle("图片水印");

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction().replace(R.id.content_frame, new WaterMarkFragment()).commit();
    }
    disPlayHomeAsUp(R.id.waterMarkToolbar);
}
 
Example #23
Source File: BookmarkEditActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mModel = new BookmarkModel();
    mBookmarkId = BookmarkId.getBookmarkIdFromString(
            getIntent().getStringExtra(INTENT_BOOKMARK_ID));
    mModel.addObserver(mBookmarkModelObserver);
    BookmarkItem item = mModel.getBookmarkById(mBookmarkId);
    if (!mModel.doesBookmarkExist(mBookmarkId) || item == null) {
        finish();
        return;
    }

    setContentView(R.layout.bookmark_edit);
    mTitleEditText = (EmptyAlertEditText) findViewById(R.id.title_text);
    mFolderTextView = (TextView) findViewById(R.id.folder_text);
    mUrlEditText = (EmptyAlertEditText) findViewById(R.id.url_text);

    mFolderTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BookmarkFolderSelectActivity.startFolderSelectActivity(
                    BookmarkEditActivity.this, mBookmarkId);
        }
    });

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    updateViewContent(false);
}
 
Example #24
Source File: MainActivity.java    From MaterialDesignColors with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

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

    DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(
            this, drawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close
    );

    mDrawerToggle.setDrawerIndicatorEnabled(true);
    drawerLayout.addDrawerListener(mDrawerToggle);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.fragment_container, new ColorPaletteFragment());
    transaction.commit();


}
 
Example #25
Source File: ReadingActivity.java    From Xndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    BrowserApp.getAppComponent().inject(this);

    overridePendingTransition(R.anim.slide_in_from_right, R.anim.fade_out_scale);
    mInvert = mPreferences.getInvertColors();
    final int color;
    if (mInvert) {
        setTheme(R.style.Theme_SettingsTheme_Dark);
        color = ThemeUtils.getPrimaryColorDark(this);
        getWindow().setBackgroundDrawable(new ColorDrawable(color));
    } else {
        setTheme(R.style.Theme_SettingsTheme);
        color = ThemeUtils.getPrimaryColor(this);
        getWindow().setBackgroundDrawable(new ColorDrawable(color));
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.reading_view);
    ButterKnife.bind(this);
    viewIdFix();

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

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

    mTextSize = mPreferences.getReadingTextSize();
    mBody.setTextSize(getTextSize(mTextSize));
    mTitle.setText(getString(R.string.untitled));
    mBody.setText(getString(R.string.loading));

    mTitle.setVisibility(View.INVISIBLE);
    mBody.setVisibility(View.INVISIBLE);

    Intent intent = getIntent();
    if (!loadPage(intent)) {
        setText(getString(R.string.untitled), getString(R.string.loading_failed));
    }
}
 
Example #26
Source File: AnagramsActivity.java    From jterm-cswithandroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_anagrams);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    AssetManager assetManager = getAssets();
    try {
        InputStream inputStream = assetManager.open("words.txt");
        dictionary = new AnagramDictionary(inputStream);
    } catch (IOException e) {
        Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
        toast.show();
    }
    // Set up the EditText box to process the content of the box when the user hits 'enter'
    final EditText editText = (EditText) findViewById(R.id.editText);
    editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
    editText.setImeOptions(EditorInfo.IME_ACTION_GO);
    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_GO) {
                processWord(editText);
                handled = true;
            }
            return handled;
        }
    });
}
 
Example #27
Source File: MainActivity.java    From CalculatorApp with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);


}
 
Example #28
Source File: ManualInputActivity.java    From polling-station-app with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manual_input);
    Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(appBar);
    Util.setupAppBar(appBar, this);
    Typeface typeFace= Typeface.createFromAsset(getAssets(), "fonts/ro.ttf");

    docNumber = (EditText) findViewById(R.id.doc_num);
    docNumber.setTypeface(typeFace);
    TextView docNumTitle = (TextView) findViewById(R.id.doc_num_title);
    TextView dobTitle = (TextView) findViewById(R.id.dob_title);
    TextView expDateTitle = (TextView) findViewById(R.id.exp_date_title);
    docNumTitle.setTypeface(typeFace);
    dobTitle.setTypeface(typeFace);
    expDateTitle.setTypeface(typeFace);

    Button submitBut = (Button) findViewById(R.id.submit_button);
    submitBut.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(verifyInput()) {
                Intent returnIntent = new Intent();
                returnIntent.putExtra(DocumentData.identifier, getData());
                setResult(Activity.RESULT_OK, returnIntent);
                finish();
            }
        }
    });
    setupDOBSpinners();
    setupExpirySpinners();

    // When docData was previously filled in, update text fields
    if(getIntent().hasExtra(DocumentData.identifier)) {
        putData(getIntent().getExtras());
    }
}
 
Example #29
Source File: SimpleActivity.java    From dttv-android with GNU General Public License v3.0 5 votes vote down vote up
protected void setToolBar(Toolbar toolbar, String title) {
    toolbar.setTitle(title);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressedSupport();
        }
    });
}
 
Example #30
Source File: AboutActivity.java    From Memory-capsule with Apache License 2.0 5 votes vote down vote up
private void inittoolbarseting(){
    toolbar_about=(Toolbar)this.findViewById(R.id.toolbar_about);
    setSupportActionBar(toolbar_about);
    getSupportActionBar().setHomeButtonEnabled(true);//设置返回键可用
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("");
    toolbar_about.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
}