开发者

dialogs problem

开发者 https://www.devze.com 2023-03-01 12:39 出处:网络
public Dialog onCreateDialog(int id){ AlertDialog.Builder builder开发者_开发百科=new AlertDialog.Builder(this);
public Dialog onCreateDialog(int id){
        AlertDialog.Builder builder开发者_开发百科=new AlertDialog.Builder(this);

        builder.setTitle("PubQuiz");


            TextView player = new TextView(this);
            player.setText("Player1");
            builder.setView(player);

            TextView team = new TextView(this);
            team.setText("TeamA");
            builder.setView(team);


        return builder.create();

       }

how do I get the second textview to show?


You should create a custom dialog for that. Take a look here: Handling buttons in custom dialogs


public Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder=new AlertDialog.Builder(this);

    builder.setTitle("PubQuiz");

    LinearLayout lay = new LinearLayout(context);
    lay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    lay.setOrientation(LinearLayout.VERTICAL);
    TextView player = new TextView(this);
    player.setText("Player1");
    lay.addView(player);

    TextView team = new TextView(this);
    team.setText("TeamA");
    lay.addView(team);

    builder.setView(lay);

    return builder.create();
}

Try this

0

精彩评论

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