2

エミュレータでアプリケーションを起動すると、アプリケーション名が表示されていないことを示すナビゲーションバーが表示されます。何が起こっているのか分かりますか?Androidスタジオアプリの名前を示すナビゲーションバーがありませんか?

public class MainActivity extends Activity implements OnClickListener { 

EditText first_name; 
EditText last_name; 
Button button_submit; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    first_name = (EditText) findViewById(R.id.first_name); 
    last_name = (EditText) findViewById(R.id.last_name); 
    button_submit = (Button) findViewById(R.id.button_submit); 
    button_submit.setOnClickListener(this); 

} 
@Override 
public void onClick(View v) { 
    Intent intent = new Intent(this, ViewActivity.class); 
    intent.putExtra("first_name", first_name.getText().toString()); 
    intent.putExtra("last_name", last_name.getText().toString()); 
    startActivity(intent); 
    } 
} 

たManifest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.yuqk.intent_usage"> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity android:name=".ViewActivity"></activity> 
</application> 

Style.xml

<resources> 
<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

参照用のスクリーンショットを参照してください..ありがとう!

screenshot

+0

xmlとjavaコードに 'toolbar 'を追加しましたか? – Ironman

答えて

3

を持っています。もしそうなら、あなたは(あなたが親parent="Theme.AppCompat.Light.DarkActionBar"または類似してstyles.xmlにAppThemeを定義したと仮定した場合)

android:theme="@style/AppTheme" 

にそれを変更する必要があります。

+0

android:theme = "@ style/AppTheme"これはデフォルトですが、何も変更しませんでした。 – gosulove

+0

あなたの 'AndroidManifest.xml'と' styles.xml'を表示してください。 – Mikhail

+0

plz check again – gosulove

1

あなたがXMLでtoolbarが含まれている場合は、右setContentView(R.layout.activity_main);

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

これはデフォルトのテーマですが、私は何も変更しませんでした。私はちょうどプロジェクトを作成して実行しました。ツールバーを表示するにはどうすれば多くのものを変更する必要がありますか? – gosulove

+0

あなたの問題はそれ以上のようです。しかし、これらのコード行もデフォルトで必須です。作業中のアプリケーションでこれらの行を削除しても、ツールバーは表示されますが、空になります。これらの行を書き、変更を参照してください – Marat

0

た後、それはあなたがStyle.xmlファイルを変更したことかもしれない、onCreate()方法の内のコード行を追加しますテーマスタイルはNoActionBar

変更してください <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

、あなたは、あなたのMainActivity.javaファイルにこのコードを追加し、この

<android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

のようなXMLファイルでtoolbarを追加する場合、この

2

チェックを実行します。

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

たManifest.xmlに、あなたはこのテーマを使用しています。

android:theme="@style/AppTheme.NoActionBar" 

のstyles.xmlあなたはおそらく、あなたのAndroidManifest.xml

android:theme="@style/AppTheme.NoActionBar" 

をこの

<!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

    <style name="AppTheme.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 
+0

android:theme = "@ style/AppTheme"これはデフォルトのテーマですが、私は何も変更しませんでした。私はちょうどプロジェクトを作成して実行しました。ツールバーを表示するにはどうすれば多くのものを変更する必要がありますか? – gosulove

+0

@gosuloveこのパターンを実行する必要があります。 'NoActionBar'テーマを設定した場合、' ActionBar'は無効になり、 'Toolabr'をその場所に追加することができます。また、' Toolbar '。 – Ironman

+0

いいえ、私は "NoActionBar"を設定しませんでした。そのデフォルトのandroid:theme = "@ style/AppTheme" – gosulove

関連する問題