I am using this code to display Alert Dialog
holder.tv1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder nointernetconnection = new AlertDialog.Builder(
temp);
nointernetconnection
.setIcon(R.drawable.ic_launcher)
.setTitle(list.get(position).getAS_name())
.setMessage(list.get(position).getDesc_art())
.setCancelable(true)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg,
int arg1) {
}
});
AlertDialog a = nointernetconnection.create();
a.show();
Message body is converted into scrollView automatically in case the text is more but Title text has not been viewed completely nor the title space is scrollable.
So, I want to expand the Title area & also want to make it scrollable & for this i don't wanna use custom Dialog, i want to only implement it by AlertDialog.
Here is my customdialogclass. It has several constructors in function of what you want to display: buttons, progress, nothing more than a title and a message... Customizing the layout you will be able to have a longer title or not. You could even insert one custom textview that adopts its font size to the space avaible for it. Hope it helps.
the interface for the buttons:
the layout:
This example is some what a typical hack... You don't need a custom
View
also...You have 2 options-
You could create a custom dialog view and show ur content. Here is an example
where R.layout.custom_alert is UI You want to show (in your case 2 textview with a button at the bottom). Ref
You can use the
.setCustomTitle
method of theAlertDialog.Builder
class, to specify a custom layout file for the title element of the dialog .(As this is still using the AlertDialog class and not a custom (or subclassed) dialog, I think it's a worthy answer). Like so:Android docs reference
.setCustomTitle(View customTitleView)
Or you could just make the title font a smaller size, but depending on how much content there is, it may become pointless even having the title there, if it's too small to read.
*You can do custom alert dialog by creating custom layout.
*create a custom XML file in re/layout folder
*you can design it in your way.
*in you activity class you have to write in on create method
i home this will be useful for you.
Dialog d = new Dialog(MainActivity.this);
d.setcontentview(R.layout.custom);
//For example you have one edit text and button than you can make it by declaring
//you can on click listner on button like
Alert alert = d.create(); d.show();
If you really do not want to use a custom title view, you can make the dialog title multiline:
If you would like to have a scrolling title, or use a custom title, Then you only (good) option would be to use a custom alertdialog title. It's not very hard to apply: