开发者

TextView inside an alert dialog won't scroll down

开发者 https://www.devze.com 2023-03-26 18:21 出处:网络
I am taking data from a website and placing inside of a text view so that I can center it using setGravity(Gravity.CENTER). However when i place the text view inside of the alert dialog I can no longe

I am taking data from a website and placing inside of a text view so that I can center it using setGravity(Gravity.CENTER). However when i place the text view inside of the alert dialog I can no longer scroll down to see the end of my message. Can someone help me with this problem? Thank You

    TextView msg1=new TextView(Welcome.this);
   //Takes data from a website
    msg1.setText(Html.fromHtml(getText("http://www.cellphonesolutions.net/welcome-en")));
    msg1.setGravity(Gravity.CENTER);
    LinearLayout dialogLayout = new LinearLayout(Welcome.this);

    dialogLayout.addView(msg1);
    dialogLayout.setOrientation(LinearLayout.VERTICAL);
    AlertDialog welcome = new AlertDialog.Builder(Welcome.this).create();
    welcom开发者_如何学编程e.setView(dialogLayout);

    welcome.setButton("OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        //rest of the code....


You can try changing the code like this:

    dialogLayout.addView(msg1);
    dialogLayout.setOrientation(LinearLayout.VERTICAL);
    AlertDialog welcome = new AlertDialog.Builder(Welcome.this).create();
    ScrollView scrollPane = new ScrollView(this);
    scrollPane.addView(dialogLayout);
    welcome.setView(scrollPane);
0

精彩评论

暂无评论...
验证码 换一张
取 消