Custom Alertdialog long text issue


Last Updated:

  1. kaliki

    kaliki Member This Topic's Starter

    Joined:
    Jan 21, 2010
    Messages:
    11
    Likes Received:
    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>

    [​IMG]
     

    Advertisement
  2. kaliki

    kaliki Member This Topic's Starter

    Joined:
    Jan 21, 2010
    Messages:
    11
    Likes Received:
    0
    Solved by adding <supports-screens> tag in android manifest
     

Share This Page

Loading...