• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Custom Alertdialog long text issue

kaliki

Newbie
Jan 21, 2010
11
0
Hi, i'm building an aplication for a WQVGA (240x400) device running android 2.1. I've added the custom dialog from here plus two buttons:
Creating Dialogs | Android Developers

The buttons appear correctly if the text is short but not if it's longer. Any idea why? Any workarounds?

This is my code:

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

AlertDialog.Builder builder;
AlertDialog alertDialog;

Context mContext = this;
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog,(ViewGroup) findViewById(R.id.layout_root));

TextView text = (TextView) layout.findViewById(R.id.text);
text.setText(getString(R.string.agreement));

builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
builder.setCancelable(false);
builder.setPositiveButton("Continue", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){

}
});
builder.setNegativeButton("Exit", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){

}
});

alertDialog = builder.create();
alertDialog.show();
}

custom_dialog.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:eek:rientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<TextView android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFF"
/>
</LinearLayout>

screeni.png
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones