1. Are you ready for the Galaxy S20? Here is everything we know so far!

Custom Alertdialog long text issue

Discussion in 'Android Development' started by kaliki, May 29, 2010.

  1. kaliki

    kaliki Newbie
    Thread Starter

    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>

    [​IMG]
     


  2. kaliki

    kaliki Newbie
    Thread Starter

    Solved by adding <supports-screens> tag in android manifest
     
Loading...

Share This Page

Loading...