Reputation: 1076
in my news app which has a navigation drawer,doesnt display the activity/app name in the toolbar,all other activity refer the app name from the Strings.xml and display respectivly in their toolbar,but the main activity which starts from the launcher just display a blank toolbar with hamburger icon,here is my manifest.please help me to fix the problem
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".app.AppController"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NewsInDetailActivity"
android:parentActivityName=".MainActivity" >
</activity>
<activity android:name=".MalayalamewsActivity" >
</activity>
<activity
android:name=".MalayalamNewsActivity"
android:parentActivityName=".MainActivity" >
</activity>
<activity
android:name=".HindiNewsActivity"
android:parentActivityName=".MainActivity" >
</activity>
<activity
android:name=".KannadaNews"
android:parentActivityName=".MainActivity" >
</activity>
<activity
android:name=".NewsDetails"
android:label="@string/title_activity_news_details"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
</application>
Upvotes: 0
Views: 345
Reputation: 1731
Ok here is a hint which should get you going, you should have something like this in your MainActivity.xml
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/holo_blue_light"
android:minHeight="100dp">
</android.support.v7.widget.Toolbar>
Then in the MainActivity.java
you should set the Toolbar like this:
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
if(toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("My title!");
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
}
Hope it helps.
Upvotes: 1