Settting Custom Title for Different screens

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Settting Custom Title for Different screens

Postby Andy » Fri Feb 06, 2009 11:01 am

[align=justify]

Hi ,


I want to set Custom Title for each screen.

ex: <image> <Title>

<Screen
Content>

I want this Custom Title functionality to be in a common Class with a method accepting a String<Title> and Image<bitmap>...which will be called from different Activities

I have tried this but since u can't manipulate a part of Activity's content(in our case Title) in different Activity.
May be we can do it with Window....
Can any one plz guide me if u you have idea!!!!!!!


Thanks in Advance!!!!!!!!!!
A n D r O i D
Andy
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Dec 19, 2008 2:53 pm

Top

Re: Settting Custom Title for Different screens

Postby Rahul » Mon Feb 09, 2009 6:56 am

The title for a screen name generally is being called from the AndroidManifest.xml.

Locate this code in ur AndroidManifest under the Activity tag

Code: Select all
android:label="@string/app_name"


This would be the default tag for any application.This is from where your screen name is being referred.So when you start a second activity(screen2) you should declare that activity in ur AndroidManifest file.While doing so just change the label name to be different from the first one.Some thing like this.

Code: Select all
android:label="@string/app_name1"


and in the Strings.xml under the values folder just add your the tag app_name1 and enter the name you would like to give for screen2.It would be called automatically now.


Regards,

Rahul



Andy wrote:[align=justify]

Hi ,


I want to set Custom Title for each screen.

ex: <image> <Title>

<Screen
Content>

I want this Custom Title functionality to be in a common Class with a method accepting a String<Title> and Image<bitmap>...which will be called from different Activities

I have tried this but since u can't manipulate a part of Activity's content(in our case Title) in different Activity.
May be we can do it with Window....
Can any one plz guide me if u you have idea!!!!!!!


Thanks in Advance!!!!!!!!!!
Rahul
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Wed Oct 01, 2008 11:16 am

Postby darolla » Tue Feb 10, 2009 8:49 am

maybe this helps: http://www.anddev.org/my_own_titlebar_b ... t4591.html

greetings,
darolla
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Postby Andy » Tue Feb 10, 2009 12:47 pm

Hi darolla,

Thanks for the post....!!

But I want to have a common code to which I can send Image and text<title> for all the different screens,but the main content will be set in the individual screens.

I am posting the sample code [ few things borrowed from ur post :) ]

Code: Select all
public class MyActivity extends Activity {

      
   
      @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
       Bitmap image = BitmapFactory.decodeResource(getApplicationContext().getResources(),
                  R.drawable.lil_opensource);
      String Title = "Amigo!";
      boolean Rq = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);   
      System.out.println(" Window Feature :"+Rq);
      setContentView(R.layout.my);
      Custom c = new Custom();
      [b]c.customtitle(Title, image,this);[/b]


   }
      }


The above code will call the common Title settting code.

Code: Select all
  public class Custom extends Activity {


   @Override
   public void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);
      
   }
    public void customtitle(String Title,Bitmap image,Activity activity) {
         
    System.out.println("Title is :"+Title);
    this.image = image;
    this.Title = Title;
    activity.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_title);
    ((RelativeLayout)findViewById(R.id.header)).setBackgroundColor(Color.WHITE);
    ((TextView)findViewById(R.id.title)).setText(Title);
    ((ImageView)findViewById(R.id.back)).setImageBitmap(image);
         
   
    }

}



But currently I am getting Null Pointer exception on the findViewById for header!!!

Can we achieve this i.e: setting a part{ Title } of the screen in one class and the rest of the content { Main } in the other class.

Please help me in this regard!!!

Thanks and Regards,
Andy
A n D r O i D
Andy
Junior Developer
Junior Developer
 
Posts: 13
Joined: Fri Dec 19, 2008 2:53 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 13 guests