Sara
この記事では、アプリの上部に表示されるアクションバーの文字列を変更する方法を紹介しています。
今回紹介するのはアクティビティごとに変更する方法 です。
アプリ全体で一括変更したい場合はアプリの表示名を変更する方法 をお読み下さい。
アクションバーの文字列を変更する アクションバーの文字列を変更したいアクティビティのファイルを開いて、3・15~18行目を追加します。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com .example .myapplication ;
import androidx .appcompat .app .ActionBar ;
import androidx .appcompat .app .AppCompatActivity ;
import android .os .Bundle ;
public class MainActivity extends AppCompatActivity {
@ Override
protected void onCreate (Bundle savedInstanceState ) {
super .onCreate (savedInstanceState );
setContentView (R .layout .activity_main );
ActionBar actionBar = getSupportActionBar ();
if (actionBar != null ) {
actionBar .setTitle ("テキスト" );
}
}
}
View the code on Gist .
ABOUT ME
書籍やオンライン講座でプログラミングを勉強してフリーランスのプログラマーになりました。
このサイトでは「わかりやすく・シンプル」をモットーに、プログラミングの基礎からアプリ開発まで紹介します。
独学でプログラミングを勉強をしている方、基礎は勉強したけれど次に何をすれば良いか分からない...という方のお役に立てるサイトを目指しています。
主な使用言語:Java / Kotlin / PHP
>> 詳しいプロフィール
>> お問い合わせ
>> 書籍を出版しました!
COMMENT
投稿いただいたコメントは管理者の承認後に表示されます。
コードやエラーに関するご質問の場合は、以下の3点
をできるだけ具体的に必ず書いてください。