I'm trying to use android.support.v7.widget.SwitchCompat to create a switch in minimum SDK of 10 and I'm getting the error android.view.InflateException: Binary XML file line #9: Error inflating class android.support.v7.widget.SwitchCompat In looking for solutions, I've found that it may have something to do with which style is declared? So I've changed the style to Theme.AppCompat but I'm still getting the error that it can't inflate. I'm fairly certain that I've got the correct support library added (I'm using Eclipse Kepler) because there are no errors at import android.support.v7.widget.SwitchCompat;. So here's all the relevant code, can anyone see where the problem is?
Manifest:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Splash"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
....
Style:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
...
</resources>
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="horizontal" >
<android.support.v7.widget.SwitchCompat
android:id="#+id/test1_SW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="25dp"
android:checked="false"
android:text="SwitchCompat"
android:textOff="OFF"
android:textOn="ON" />
</RelativeLayout>
Activity:
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.SwitchCompat;
import android.util.Log;
import android.widget.CompoundButton;
public class SwitchTest extends Activity implements
CompoundButton.OnCheckedChangeListener {
private SwitchCompat test1_SW;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.cutin, R.anim.cutout);
setContentView(R.layout.switch_test);
// --- one
test1_SW = (SwitchCompat) findViewById(R.id.test1_SW);
test1_SW.setSwitchPadding(40);
test1_SW.setOnCheckedChangeListener(this);
// --- END one
}
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.test1_SW:
Log.i("test1_SW", isChecked + "");
break;
}
}
}
The problem is your Activity is extending android.app.Activity, and not the support Activity you need to use with the AppCompat libraries. Just change:
import android.app.Activity;
to
import android.support.v7.app.ActionBarActivity;
Or, since I think that's been deprecated in API 22:
import android.support.v7.app.AppCompatActivity;
Once you change those it should work.
Related
I am so close. I have the android studio project set up correctly with libs, the project compiles, and the emulators and device run the app. I am trying to get rid of the bottom button popup menu of older devices and replace with v7 appcompat toolbar. The old action bar is gone but the menu inflate still inflates to the old popup menu.
I start off using a splashscreen then the app main shows the database view activity. This means I have to dynamically load the toolbar.
My thinking now is the only place I have left to work out is the styles/themes or the order of setcontent(this) to display the main app/database view screen.
Also I dont have the correct emulator for the HTC evo device so the device buttons dont show. I believe this is why alot of developers post that the toolbar doesnt show. When I install apk on real device i can the use the menu button. This is how I am able to see that the menu is not in the toolbar. The emulator shows no buttons plus no toolbar so a developer on an emulator of newer devices would never see this.
I hope this enough to go on for any one to catch my pitfall here.
Thanks in advance.
Here are codes snippets:
styles.xml:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<!--<style name="AppTheme" parent="AppBaseTheme">-->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="windowNoTitle">true</item>
<item name="windowActionBar">true</item>
<item name="android:textColor">#000000</item>
</style>
</resources>
Toolbarmenu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item
android:id="#+id/add"
android:icon="#android:drawable/ic_menu_add"
app:showAsAction="ifRoom"
android:title="#string/app_name"/>
<item
android:id="#+id/reset"
android:icon="#android:drawable/ic_menu_revert"
app:showAsAction="ifRoom"
android:title="#string/action_settings"/>
<item
android:id="#+id/about"
android:icon="#android:drawable/ic_dialog_info"
app:showAsAction="ifRoom"
android:title="#string/hello_world">
</item>
<item
android:id="#+id/exit"
app:showAsAction="ifRoom"
android:title="#string/Menu">
</item>
</menu>
Manifest.xlm:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.loadrunner"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.loadrunner.SplashScreenActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.loadrunner.MainActivity"
android:exported="true"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
lrtoolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:background="#2196f3"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:minHeight="200dp">
</android.support.v7.widget.Toolbar>
</LinearLayout>
Layout_main.xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".SplashScreenActivity"
android:visibility="visible"
android:background="#color/black">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageViewSplashLogo"
android:src="#drawable/shoppingcartloading"
android:visibility="visible"
android:contentDescription="#string/app_name"
android:scaleType="fitCenter"
android:cropToPadding="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#color/black" />
</RelativeLayout>
And finally the code:
import android.app.ActionBar;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.SpinnerAdapter;
import android.widget.Toast;
import com.Table.TableMainLayout;
public class MainActivity extends AppCompatActivity {
final String TAG = "MainActivity.java";
public static DatabaseHandler db;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Log.d("SplashMainActivityonCre", "made it");
db = new DatabaseHandler(this);
db.getWritableDatabase();
db.insertFast(100);
int dbreccnt = db.countRecords();
//Log.d("SplashAfterDBCreate", "made it");
//Log.d("AppLoadrunner ", "Loadrunner record count " + dbreccnt);
Toolbar LrToolBar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(LrToolBar);
//getSupportActionBar().setDisplayShowHomeEnabled(true);
//LrToolBar.setNavigationContentDescription(getResources().getString(R.string.app_name));
setContentView(new TableMainLayout(this));
TableMainLayout start:
package com.Table;
import android.content.Context;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
//import android.database.Cursor;
import com.loadrunner.DatabaseHandler;
import com.loadrunner.R;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class TableMainLayout extends RelativeLayout {
public final String TAG = "TableMainLayout.java";
I have maybe the answer : you just get your toolbar before setContentView() method...
Just try this :
setContentView(new TableMainLayout(this));
Toolbar LrToolBar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(LrToolBar);
//getSupportActionBar().setDisplayShowHomeEnabled(true);
//LrToolBar.setNavigationContentDescription(getResources().getString(R.string.app_name));
Hope it will help you
Make your Toolbar layout like thie:
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:background="#2196f3"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:minHeight="200dp" />
and in your Activity code replace the Toolbar LrToolBar = (Toolbar) findViewById(R.id.toolbar); with the:
Toolbar toolbar = LayoutInflater.from(this).inflate(R.layout.toolbar_layout_name, null)
setSupportActionBar(toolbar);
Hope it works.
Try this:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionModeOverlay">true</item>
<item name="windowActionBar">false</item> //see this line
<item name="android:windowNoTitle">true</item>
</style>
Try setting <item name="windowActionBar">false</item>
I hope this helps!
Below is the code and I could not found solutions for displaying icon.I found difficulty to display icon for ActionBar in Android VS 1.5 with SDK 21.0.
Below is the code and I could not found solutions for displaying icon.
style.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="actionBarStyle">#style/ActionBar</item>
</style>
<style name="ActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/red</item>
<item name="background">#color/red</item>
<item name="android:icon">#mipmap/ic_launcher</item>
<item name="icon">#mipmap/ic_launcher</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.saisunsolutions.ifinco">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".splaseActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
splashActivity.java
package com.saisunsolutions.ifinco;
import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.TypefaceSpan;
public class splaseActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splase);
}
}
you should create android resource directory with menu name then inside menu create action_bar.xml like this
<item
android:id="#+id/action_bar_refresh"
android:icon="#drawable/ic_refresh"
app:showAsAction="always"
android:title="test"/>
then in your activity override onCreateOptionMenu like below
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.action_bar,menu);
return super.onCreateOptionsMenu(menu);
}
I have written an application for android API 14. When I am trying to run this app on emulator using Galaxy Nexus API 22, it shows fine, with all the colors and styles that I have programmed for. This is the screenshot:
But when I try to run it on my Asus Fonpad 7 that runs Android 5, it seems that non of my styles are honored. The application uses the default UI. Screenshot is as follows:
Can anyone help me with this? Please do let me know if any code snippets are required, since I am new to Android.
Notes:
Images are scaled down.
I am using Android Studio 1.2.2
Codes:
main_activity.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:padding="12dp"
android:orientation="vertical"
android:baselineAligned="false"
android:background="#color/kh_background">
<Button
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="#string/btn_shopping_details"
android:background="#ff02d0cb"
android:textColor="#android:color/white" />
<Button
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="#string/btn_shopping_items"
android:background="#color/kh_button_primary"
android:layout_marginTop="10dp"
android:textColor="#android:color/white" />
<Button
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="#string/btn_users"
android:background="#color/kh_button_primary"
android:layout_marginTop="10dp"
android:textColor="#android:color/white" />
<Button
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="#string/btn_reports"
android:background="#color/kh_button_primary"
android:layout_marginTop="10dp"
android:textColor="#android:color/white" />
</LinearLayout>
style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppOrangeBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/kharidariActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/kharidariActionBar</item>
</style>
<!-- Style for the app's action bar -->
<style name="kharidariActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="background">#drawable/actionbar_background</item>
</style>
</resources>
values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="kh_orange">#ffec704f</color>
<color name="kh_background">#ff474b66</color>
<color name="kh_button_primary">#ff02d0cb</color>
</resources>
MainActivity.java
package com.baktash93.kharidari;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.baktash93.kharidari" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_kharidari"
android:label="#string/app_name"
android:theme="#style/AppOrangeBarTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Update:
I installed the same application on Asus Fonpad 7 with Android 4.4.3 and Galaxy S3 with Android 4.3 and one both it was showing fine, with all the layouts customized. Any idea now?
try changing the style.xml to its default values given below, I guess your problem may be in the custom #drawables/resource_values you are using in style.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resource
From some doucment , I know ActionBarActivity display app title by default. I create a Activity with eclipse, I have set android:theme as android:Theme.Light, I find the Activity still display Title by default, why?
package com.example.aa;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aa"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="21" />
<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" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
Try setting this to your activity declared in the manifest:
android:theme="#android:style/Theme.NoTitleBar"
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here);
Be certain to put it before the call to setContentView(R.id.x), otherwise it will crash. The reason wasn't immediately obvious to me. 08-13 12:47:33.561 E/AndroidRuntime( 9125): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.SplashActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
I am working on a xamarin project (has no relevance here as far as I can tell - the android layout properties are the same)
I am using Window.SetFeatureInt (WindowFeatures.CustomTitle, ...) to set the title (2 "columns". I wish to make two rows of text though for my title. Is this possible? I have not had much success. I have an upper left, upper right and lower left and lower right TextViews to set.
My previous attempts have ended up with the TextViews overwriting each other.
Here I am designing a XML file with an image, text for title & button. This is the XML file. U can use it however you want, for a complete application or perticular activity.
In case of activity add this activity's theme tag. For multi line just use text view in side the below linear layout, set it as multline true.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:gravity="center_vertical"
android:background="#android:color/darker_gray">
<ImageView
android:id="#+id/header"
android:background="#drawable/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom Window Text"
android:textColor="#android:color/black"
android:textStyle="bold"/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
Create a theme in Custom_theme.xml,
<resources>
<style name="CustomWindowTitleBarBG">
<item name="android:background">#323331</item>
</style>
<style name="TitleBarTheme" parent="android:Theme">
<item name="android:windowTitleSize">35dip</item>
<item name="android:windowTitleBackgroundStyle"> #style/CustomWindowTitleBarBG</item>
</style>
Modify the AndroidManifest.xml file as follows for applying custom theme
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/TitleBarTheme" >
<activity
android:name=".CustomWindowTitle"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Now in main java file add “requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)” &
“getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title)”
This is the code snippet for CustomWindowTitle.java
package com.example.android;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
public class CustomWindowTitle extends Activity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
}
}