Dialog with No Title

919 views
Skip to first unread message

G

unread,
Nov 13, 2008, 1:26:53 PM11/13/08
to Android Developers
I've got the following NumberPickerDialog class which extends Dialog.
Currently the pick_number.xml contains only a LinearLayout and 1
button (this is all incomplete as i'm still in early dev stages). When
I show this dialog, I get a blank space for the title even though I do
not specify one. I would like that blank space gone, so i have more
room on screen for more buttons. How do I create this dialog with no
title/empty spot for title? I've tried setTitle(null) which didnt
work, and setTheme(android.R.style.Theme_NoTitle) which is not
supported by the Dialog class.

Thanks a lot.
/g

public class NumberPickerDialog extends Dialog {

public interface OnNumberChangedListener {
void numberChanged(int number);
}

private OnNumberChangedListener mListener;
private int mInitialNumber;
private int mMinNumber;
private int mMaxNumber;

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.pick_number);
//setTitle("THIS SHOULDNT BE HERE");

Button btn = (Button)findViewById(R.id.Button01);
btn.setOnClickListener(new Button.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
String num = ((Button)v).getText().toString();
mListener.numberChanged(Integer.parseInt(num));
dismiss();
}

});
}

public NumberPickerDialog(Context ctx, OnNumberChangedListener
listener, int initialNumber, int minNumber, int maxNumber) {
super(ctx);
mListener = listener;
mInitialNumber = initialNumber;
mMinNumber = minNumber;
mMaxNumber = maxNumber;
}
}

Message has been deleted

Christine

unread,
Dec 7, 2008, 6:58:24 AM12/7/08
to Android Developers
When you set the view to "invisible", it won't take up space:
yourTextView.setVisibility(TextView.INVISIBLE)


On Dec 7, 4:09 am, cyntacks <kevin.clout...@cyntacks.com> wrote:
> I'm just bumping this, I have been trying to figure this out for the
> past 2 hours... anyone know how this can be done?
>
> On Nov 13, 1:26 pm, G <ghack...@gmail.com> wrote:
>
> > I've got the following NumberPickerDialog class which extendsDialog.
> > Currently the pick_number.xml contains only a LinearLayout and 1
> > button (this is all incomplete as i'm still in early dev stages). When
> > I show thisdialog, I get a blank space for thetitleeven though I do
> > not specify one. I would like that blank space gone, so i have more
> > room on screen for more buttons. How do I create thisdialogwith notitle/empty spot fortitle? I've tried setTitle(null) which didnt

cyntacks

unread,
Dec 7, 2008, 8:19:36 AM12/7/08
to Android Developers
Sure, that is what I had originally thought. But how do you get the
Title view in order to set it to GONE (I believe INVISIBLE still takes
up some space)?

Xavier Mathews

unread,
Dec 7, 2008, 10:25:17 AM12/7/08
to android-d...@googlegroups.com
Did you set it to invisable and shorten it? I have never heard of a
Dialog with no title.
--
Xavier A. Mathews
Student/Browser Specialist/Developer/Web-Master
Google Group Client Based Tech Support Specialist
Hazel Crest Illinois
xavier...@gmail.com¥xavier...@hotmail.com¥trues...@yahoo.com
"Fear of a name, only increases fear of the thing itself."

cyntacks

unread,
Dec 7, 2008, 10:41:36 AM12/7/08
to Android Developers
I guess it depends on how you define "dialog". As it stands in the SDK
now a dialog can be used for almost anything, for example you can
display an error to the user or even get input from the user. The
issue mainly revolves around spacing, especilly when the device is in
Landscape.

1) If I were to show an AlertDialog, of course I want to have a title
(something like "Error: Nothing Found...").

2) But, if I am attempting to use the dialog to retrieve user input
like for example user information (address, email, phone, etc etc)
there is no need for the title. Using the EditText's "hint text", I
can simply add "Email Address" as a hint, and the title becomes
redundant.

Again, this is really a question of screen real estate and the title
just takes up too much room on a device in Landscape mode.

Any ideas besides writing an activity that "looks" like a dialog?

Kevin

On Dec 7, 10:25 am, "Xavier Mathews" <xavieruni...@gmail.com> wrote:
> Did you set it to invisable and shorten it? I have never heard of aDialogwith notitle.
>
> On 12/07/2008, cyntacks <kevin.clout...@cyntacks.com> wrote:
>
>
>
>
>
> > Sure, that is what I had originally thought. But how do you get the
> >Titleview in order to set it to GONE (I believe INVISIBLE still takes
> xavieruni...@gmail.com¥xavieruni...@hotmail.com¥truestar...@yahoo.com

Xavier Mathews

unread,
Dec 7, 2008, 10:56:08 AM12/7/08
to android-d...@googlegroups.com
Nope i think Kevin is right. Get A bigger screen. lol jokeing.

On 12/07/2008, cyntacks <kevin.c...@cyntacks.com> wrote:
>
xavier...@gmail.com¥xavier...@hotmail.com¥trues...@yahoo.com

cyntacks

unread,
Dec 7, 2008, 11:02:10 AM12/7/08
to Android Developers
Ha!!! That's too funny. I wish it were as simple as that!

This is just one of those things, I am about 30 minutes from deploying
and I just can't get myself to do it without "fixing" this little
problem. My dialog just looks terrible in Landscape because it
actually contains a listview allowing the user to scroll through some
content and select something. The title takes up so much room I am
afraid those of us with fat fingers (read: less technically inclined)
will have difficulty with the listview...

Argh,,,,

Kevin

On Dec 7, 10:56 am, "Xavier Mathews" <xavieruni...@gmail.com> wrote:
> Nope i think Kevin is right. Get A bigger screen. lol jokeing.
>

Froilan

unread,
Jan 4, 2009, 5:58:21 PM1/4/09
to Android Developers
Just add:
requestWindowFeature(Window.FEATURE_NO_TITLE);

Cheers
Reply all
Reply to author
Forward
0 new messages