Java Code Examples for android.support.v7.app.ActionBar.setTitle()

The following are Jave code examples for showing how to use setTitle() of the android.support.v7.app.ActionBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Khonsu   File: HomeFragment.java   View Source Code Vote up 6 votes
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //set up databaseOpenHelper and Retrofit objects.
    mAPI = ApiUtils.getServerAPI();
    dbHelper = new DatabaseOpenHelper(getContext());
    sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());

    //fetch data from online JSON if it is not updated
    if(!sharedPref.getBoolean(getString(R.string.updated_database), false)) {
        getDataFromJSON();
    }

    ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (actionBar != null) {
        actionBar.show();
        actionBar.setTitle(R.string.home);
    }
}
 
Example 2
Project: IdeaTrackerPlus   File: MainActivity.java   View Source Code Vote up 6 votes
private void selectFavoriteProject() {

        if (!mNoProject) {
            mSelectedProfileIndex = getIndexOfFavorite();
            IProfile activeProfile = mProfiles.get(mSelectedProfileIndex);
            String activeProfileName = activeProfile.getName().getText();

            ActionBar bar;
            if ((bar = getSupportActionBar()) != null) {
                bar.setTitle(activeProfileName);
            }

            DataEntry.setTableName(activeProfileName);

            switchToProjectColors();
        }
    }
 
Example 3
Project: Phoenix-for-VK   File: CreatePhotoAlbumFragment.java   View Source Code Vote up 6 votes
@Override
public void onResume() {
    super.onResume();
    ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
    if (actionBar != null) {
        actionBar.setTitle(R.string.create_album);
        actionBar.setSubtitle(null);
    }

    new ActivityFeatures.Builder()
            .begin()
            .setBlockNavigationDrawer(true)
            .setStatusBarColored(true)
            .build()
            .apply(getActivity());
}
 
Example 4
Project: thingplug-sdk-android   File: SensorListActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sensor_list);

    ActionBar bar = getSupportActionBar();
    bar.setTitle(R.string.actionbar_list);

    sensorListener = new SensorListener(this, sensorInfos);

    userInfo = UserInfo.getInstance(this);

    oneM2MWorker = OneM2MWorker.getInstance();
    oneM2MWorker.setStateListener(new OneM2MWorkerListener());

    googleDriveHandler = new GoogleDriveHandler(this, new GoogleDriveCommandListener());
    googleDriveHandler.connect();

    // create sensor list
    createSensorList();
}
 
Example 5
Project: TurboChat   File: MessageActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_root);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    final ActionBar supportActionBar = getSupportActionBar();
    final Team team = getIntent().getExtras().getParcelable(ARG_TEAM);
    supportActionBar.setTitle(team.getName());
    supportActionBar.setSubtitle(getString(R.string.messages_subtitle));
    supportActionBar.setDisplayHomeAsUpEnabled(true);
    inflateFragment(team);

}
 
Example 6
Project: weex-3d-map   File: WXPageActivity.java   View Source Code Vote up 5 votes
private void initUIAndData() {

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

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mUri.toString().substring(mUri.toString().lastIndexOf(File.separator) + 1));

    mContainer = (ViewGroup) findViewById(R.id.container);
    mProgressBar = (ProgressBar) findViewById(R.id.progress);
    mWXHandler = new Handler(this);
    HotRefreshManager.getInstance().setHandler(mWXHandler);
    addOnListener();
  }
 
Example 7
Project: Phoenix-for-VK   File: RepostFragment.java   View Source Code Vote up 5 votes
@Override
public void onResume() {
    super.onResume();
    ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
    if (actionBar != null) {
        actionBar.setTitle(R.string.share);
        actionBar.setSubtitle(null);
    }
}
 
Example 8
Project: XFrame   File: BaseActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    super.onCreate(savedInstanceState);
    String title=getIntent().getStringExtra("title");
    if (TextUtils.isEmpty(title))
        title=getString(R.string.app_name);
    ActionBar bar=getSupportActionBar();
    bar.setTitle(title);
    if (!title.equals(getString(R.string.app_name)))
        bar.setDisplayHomeAsUpEnabled(true);
}
 
Example 9
Project: Phoenix-for-VK   File: GifPagerFragment.java   View Source Code Vote up 5 votes
@Override
public void setToolbarTitle(@StringRes int titleRes, Object... params) {
    ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
    if (Objects.nonNull(actionBar)) {
        actionBar.setTitle(getString(titleRes, params));
    }
}
 
Example 10
Project: JKCloud   File: EditOpportunityActivity.java   View Source Code Vote up 5 votes
@Override
protected void initView(Bundle savedInstanceState) {
    if (mToolbar != null) {
        setSupportActionBar(mToolbar);
        ActionBar mActionBar = getSupportActionBar();
        if (mActionBar != null) {
            mActionBar.setDisplayHomeAsUpEnabled(true);
            mActionBar.setTitle("编辑商机");
        }
    }
    showLoading();
}
 
Example 11
Project: dkplayer   File: VodPlayerActivity.java   View Source Code Vote up 5 votes
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vod_player);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setTitle("VOD");
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
        ijkVideoView = findViewById(R.id.player);
//        int widthPixels = getResources().getDisplayMetrics().widthPixels;
//        ijkVideoView.setLayoutParams(new LinearLayout.LayoutParams(widthPixels, widthPixels / 16 * 9));

        List<VideoModel> videos = new ArrayList<>();
        videos.add(new VideoModel(URL_AD, "广告", new AdController(this)));
        videos.add(new VideoModel(URL_VOD, "这是一个标题", new StandardVideoController(this)));

        ijkVideoView
                .setVideos(videos)
//                .autoRotate()
//                .enableCache()
//                .useSurfaceView()
//                .useAndroidMediaPlayer()
//                .setUrl(URL_VOD)
//                .setTitle("网易公开课-如何掌控你的自由时间")
                .start();
    }
 
Example 12
Project: BuddyBook   File: DetailActivityFragment.java   View Source Code Vote up 5 votes
private void loadToolbar(final Book book) {
    if (getActivity() != null) {
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null) {
            actionBar.setTitle(book.getVolumeInfo().getTitle());
            actionBar.setSubtitle(book.getVolumeInfo().getAuthors() != null ? book.getVolumeInfo().getAuthors().get(0) : "");
        }
    }
}
 
Example 13
Project: Ocr-android   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public void onShow(String title) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(title);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }
}
 
Example 14
Project: MovieApp   File: MovieListFragment.java   View Source Code Vote up 4 votes
private void init(View view) {
    ButterKnife.bind(this, view);

    activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(fragmentTitle);
    }

    recyclerView.setHasFixedSize(true);
    recyclerView.setMotionEventSplittingEnabled(false);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(movieListAdapter);
    recyclerView.setLayoutManager(setUpLayoutManager());
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addOnScrollListener(setupScrollListener(recyclerView.getLayoutManager()));

    tryAgainBtn.setOnClickListener(v -> {
        switch (ID) {
            case 1:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.mostPopularListRequested();
                }
                break;
            case 2:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.onTopRatedMoviesRequested();
                }
                break;
            case 3:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.onBoxOfficeRequested();
                }
                break;
            case 4:
                if(movieListAdapter.isEmpty()) {
                    movieListPresenter.onPopularMovieByGenreRequested(genreId);
                }
                break;
        }
    });

}
 
Example 15
Project: CodeWatch   File: LeaderboardFragment.java   View Source Code Vote up 4 votes
private void setActionBarTitle(String title) {
    ActionBar actionBar = ((NavigationDrawerActivity) getActivity()).getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(title);
    }
}
 
Example 16
Project: ANNO1404-Warenrechner-App   File: MaterialDetailFragment.java   View Source Code Vote up 4 votes
@Override
protected void onViewCreated(View parent) {
    getGameActivity().component().inject(this);

    gameActivity.setSupportActionBar(toolbar);
    final ActionBar actionBar = gameActivity.getSupportActionBar();

    setHasOptionsMenu(true);

    chain = gson.fromJson(getArguments().getString(GameActivity.BUNDLE_CHAIN_KEY), ProductionChain.class);

    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(game.getName());
        actionBar.setSubtitle(gameActivity.getString(R.string.production_chain_title,
                chain.getBuilding().getProduces().getName(getContext())));
    }
    registerLifecycle(adapter);
    chainsRV.setLayoutManager(new LinearLayoutManager(gameActivity));
    chainsRV.setItemAnimator(new DefaultItemAnimator());
    chainsRV.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
    adapter.init(chain);
    chainsRV.setAdapter(adapter);

    final ImageView imageView = (ImageView) animPlaceholder.findViewById(R.id.itemChainsImage);
    imageView.setImageDrawable(chain.getBuilding().getProduces().getDrawable(getContext()));

    final TextView chainsText = (TextView) animPlaceholder.findViewById(R.id.itemChainsText);
    chainsText.setText(chain.getBuilding().getProduces().getName(getContext()));

    final NumberPicker numberPicker = (NumberPicker) animPlaceholder.findViewById(R.id.itemChainsNumberPicker);
    numberPicker.setValue(chain.getChains());

    final TextView tpmText = (TextView) animPlaceholder.findViewById(R.id.tpm);
    tpmText.setText(
            getContext().getString(R.string.tpm, chain.getBuilding().getTonsPerMin() * chain.getChains())
    );

    ViewCompat.setTransitionName(animPlaceholder, chain.getBuilding().name());

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        animPlaceholder.setVisibility(View.GONE);
        chainsRV.setAlpha(1f);
    }
}
 
Example 17
Project: kolibri-android   File: KolibriNavigationActivity.java   View Source Code Vote up 4 votes
protected void setActionBarTitle(String title) {
  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null && title != null) {
    actionBar.setTitle(title);
  }
}
 
Example 18
Project: MaterialLearning   File: WeTalkActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_we_talk);

    initMsgs();
    recyclerView= findViewById(R.id.recycler_view_weTalk);
    Toolbar toolbar=  findViewById(R.id.toolbar_weTalk);
    Button button= findViewById(R.id.send);
      editText=  findViewById(R.id.editText);

    setSupportActionBar(toolbar);
    ActionBar actionBar= getSupportActionBar();
    if(actionBar!=null)
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle("你好,小娜(Fake Cortana)");

    //设置recyclerView
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    adapter=new WeTalkAdapter(msgList);
    recyclerView.setAdapter(adapter);

    //监听send按钮,将editText中的文字取出来放入消息列表中
    button.setOnClickListener(new View.OnClickListener() {
                                  @Override
                                  public void onClick(View v) {
                                      String content = editText.getText().toString();
                                      Msg msg = new Msg(content,Msg.TYPE_SEND);
                                      msgList.add(msg);
                                      adapter.notifyItemInserted(msgList.size()-1);
                                      recyclerView.scrollToPosition(msgList.size()-1);
                                      editText.setText("");
                                      //加入随机消息,模拟小娜的回复
                                      msgList.add(randomMsg());
                                      adapter.notifyItemInserted(msgList.size()-1);
                                      recyclerView.scrollToPosition(msgList.size()-1);
                                  }
                              }
    );


}
 
Example 19
Project: Phoenix-for-VK   File: ActivityUtils.java   View Source Code Vote up 4 votes
public static void setToolbarTitle(Fragment fragment, String title){
    ActionBar actionBar = supportToolbarFor(fragment);
    if(Objects.nonNull(actionBar)){
        actionBar.setTitle(title);
    }
}
 
Example 20
Project: TicketView   File: BaseActivity.java   View Source Code Vote up 4 votes
public void setActivityTitle(int title) {
    ActionBar toolbar = getSupportActionBar();
    if (toolbar != null)
        toolbar.setTitle(title);
}