Reputation: 187
In TabHost
we can do getActionBar().setTitle("ACTITIVTY TITLE")
.
But what about in the intent
?
Is there possible way to set title in intent
?
code
Intent i = new Intent(MenuActivity.this, DrawerListActivity.class);
startActivity(i);
Toast.makeText(getBaseContext(), "RF number: " +
KEY_RFnumber, Toast.LENGTH_SHORT).show();
Upvotes: 1
Views: 4746
Reputation: 3881
MainActivity.class
public void send(View view) {
Intent intent = new Intent(this, DrawerListActivity.class);
String message = "Drawer Title";
intent.putExtra("key", message);
startActivity(intent);
}
DrawerListActivity.class, in onCreate()
String message = getIntent().getStringExtra("key").toString(); // Now, message has Drawer title
setTitle(message);
Now, set this message as Title.
Upvotes: 6
Reputation: 409
i just paste another person answer regarding this question may be it will help you
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name_full" >
//This is my custom title name on activity. <- The question is about this one.
<intent-filter android:label="@string/app_launcher_name" > //This is my custom Icon title name (launcher name that you see in android apps/homescreen)
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Upvotes: 0
Reputation: 187
I got it! I just declare from my MainActivity a public static String that holds a string which I set in my Intent, then it call to my DrawerListActivity. It works perfectly! Thanks.
Upvotes: 0
Reputation: 26
You can't set the title directly with the intent. You could pass along the title in the intent, and have your target activity extract the title from the intent and set it. This would only be a few lines of extra code in the target activity.
Upvotes: 1