How to set the title not display? - android

It can remove title by setting requestWindowFeature(Window.FEATURE_NO_TITLE) in onCreat(). But the title display first, then disappear. How could the title not display? Could it set in manifest file?

Use like this in your manifest file:-
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar" >

just permission in activity which u want to have no title
android:theme="#android:style/Theme.NoTitleBar"

use like this way..
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
}

If you just want the default theme and no title, you can put this in your manifest file:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" >
You can also set it from the Theme drop-down menu above your layout in eclipse.

You should always use the requestWindowFeature(Window.FEATURE_NO_TITLE) before using the setContentView
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.your_layout);
}

Related

How to remove android activity label (activity title) and label bar?

I added android:theme="#android:style/Theme.NoTitleBar" to the manifest file but the app doesn't open. I want to remove the Activity label in which the name of the Activity is written.
Here is part of manifest file:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar"
>
You need to change extends in your MainActivity.
Change this
public class MainActivity extends AppCompatActivity {
}
For this
public class MainActivity extends Activity {
}
Set
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
You can use the
requestWindowFeature(Window.FEATURE_NO_TITLE) Just insert in it immediately after your onCreate function
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);}
You may have to change your extends AppCompatActivity to extends Activity sometimes to work without error

Android Hide Title Bar With Removing Appcompat Theme

ManinActivity.java
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Light.NoTitleBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I tried
requestWindowFeature(Window.FEATURE_NO_TITLE);
feature but it just won't work ! i don't able to find out why.
but when i use
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.NoActionBar">
it just worked !!! but i don't want to use Theme can i do it pragmatically ?
There are two ways to do that
Set below lines to your styles.xml
<item name="windowActionBar">false</item>
Or
Set below lines in your ActionBarActivity file.
getSupportActionBar().hide();
#Override
protected void onCreate(Bundle savedInstanceState) {
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
}

Android: How to hide/remove the taskbar

i'm using the code below and it doesn't work. i don't know why. please help.
public class FullScreen extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
To hide Action bar simply use -
ActionBar actionBar = getActionBar();
actionBar.hide();
To hide status bar add this to your activity tag in manifest -
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Try the following in the manifest file:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>
You should type in AndroidManifest.xml file:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
</activity>

Cocos2d Android Lock Screen or Leaving Game Forces Restart

I am in the final stages of a Cocos2d - Android game and I am having a problem that I can't figure out.
When I lock my tablet (Nexus 7) or when I hit the home button to leave the game, it restarts. It goes right back to the splash screen like the game is opening all over again. For your reference, here is my Main Activity and my Android Manifest:
public class MainActivity extends Activity {
//To get a static reference to context for shared preferences
private static Context context;
protected CCGLSurfaceView _glSurfaceView;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//To get a static reference to context for shared preferences
MainActivity.context = getApplicationContext();
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
_glSurfaceView = new CCGLSurfaceView(this);
setContentView(_glSurfaceView);
}
//To get a static reference to context for shared preferences
public static Context getAppContext(){
return MainActivity.context;
}
#Override
public void onStart()
{
super.onStart();
CCDirector.sharedDirector().attachInView(_glSurfaceView);
CCDirector.sharedDirector().setDeviceOrientation(CCDirector.kCCDeviceOrientationPortrait);
CCDirector.sharedDirector().setDisplayFPS(true);
CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);
CCScene scene = Splash.scene();
CCDirector.sharedDirector().runWithScene(scene);
}
#Override
public void onPause()
{
super.onPause();
CCDirector.sharedDirector().pause();
SoundEngine.sharedEngine().pauseSound();
}
#Override
public void onResume()
{
super.onResume();
CCDirector.sharedDirector().resume();
SoundEngine.sharedEngine().resumeSound();
}
#Override
public void onStop()
{
super.onStop();
SoundEngine.sharedEngine().pauseSound();
}
and
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bigfiresoftware.alphadefender"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/adicon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="bigfiresoftware.alphadefender.MainActivity"
android:screenOrientation="portrait"
android:label="#string/app_name"
android:hardwareAccelerated="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
android:configChanges="keyboard|keyboardHidden|orientation"
</manifest>
Any/all help is very much appreciated. Thanks.
add below line in your manifest file to your activity.
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
when you locked the screen the orientation of your screen changes.So that your activity destroys and again it creates.If you ad this line your orientation will not change.
The answers above didn't fix it but I finally found the answer. This was a tough one.
If anyone else finds this problem:
Remove the targetSdkVersion in AdnroidManifest.xml. Or change to some others, I haven't tried others but removal worked.
android:minSdkVersion="9"
android:targetSdkVersion="17" /> //git rid of this guy
add this line in your onstop() method
CCDirector.sharedDirector().end();
and you need to write an onDestroy() method to remove all the instances when you close the game.

How to change android Activity label

I have created an Activity and declared in Manifest file. But I would like to re-use the same Activity for other purpose.
<activity
android:configChanges="orientation|keyboardHidden"
android:label="Main Menu"
android:name=".MainMenu"
android:theme="#android:style/Theme.Light" >
</activity>
I need to change the Label dynamically. Thanks in Advance
Use
setTitle(int titleId)
or
setTitle(CharSequence title)
public class YourActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
setTitle(R.string.your_title);
setContentView(R.layout.main);
}
}
You need to use setTitle for this:
setTitle(R.string.your_title);
//or
setTitle("new title");
You can define the string in res/string.xml file and then add android:label to the AndroidMenifest.xml file
string.xml code
<string name="string_name">text to display</string>
AndroidMenifest.xml code
<activity android:name=".SomeActivity"
android:label="#string/string_name"/>
I have the same problem, Try this in onCreate it's work for me!
public class YourActivityName extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
setTitle("Your Title");
}
}
if(Condition)
{
setTitle("Your Title");
}
else
{
// your Default Title from Manifest
}
Try to use this line.
Static, not Dynamic
Go to your AndroidManifest.xml file and add the android:label attribute to the activity tag you want, like this:
<activity android:name=".name" android:label="label"/>
In your Manifest file
Initially, your code was like this.
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NumbersActivity" />
<activity android:name=".FamilyMembersActivity" />
<activity android:name=".ColorsActivity" />
<activity android:name=".PhrasesActivity" />
</activity>
</application>
But after changes to add Labels.
<activity android:name=".NumbersActivity" android:label="Numbers" />
<activity android:name=".FamilyMembersActivity" android:label="Family Members" />
<activity android:name=".ColorsActivity" android:label="Colors" />
<activity android:name=".PhrasesActivity" android:label="Phrases" >
</activity>
</application>
is the optimum way to change the Label name.
courtesy.(ryanwaite28)
User this
#Override
public void onCreate(Bundle savedInstanceState) {
setTitle("Your Title");
}
android:label="any word you want"/>

Categories

Resources