在启动MainActivity之前,我如何尝试过布局布局对话框,我尝试了很多事情,但都无济于事,是否可以在不修改Android清单中的启动器的情况下启动此布局?预先感谢您的帮助。
公共类MainActivity扩展了AppCompatActivity { 对话框mydialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mydialog = new Dialog(this);
Button button =(Button)findViewById(R.id.button);
Button button2 =(Button)findViewById(R.id.button2);
Button button3 =(Button) findViewById(R.id.button3);
Button button4=(Button) findViewById(R.id.button4);
Button button5 =(Button) findViewById(R.id.button5);
Button button6 =(Button) findViewById(R.id.button6);
Button button7 =(Button) findViewById(R.id.button7);
Button button8 =(Button) findViewById(R.id.button8);
Button button9 =(Button) findViewById(R.id.button9);
Button button10 =(Button) findViewById(R.id.button10);
Button button11 =(Button) findViewById(R.id.button11);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int1= new Intent(MainActivity.this,buttActivity.class);
startActivity(int1);
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int2= new Intent(MainActivity.this,butt2Activity.class);
startActivity(int2); }
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int3 = new Intent(MainActivity.this, butt3Activity.class);
startActivity(int3);
}
});
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int4 = new Intent(MainActivity.this, butt4Activity.class);
startActivity(int4);
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int5 = new Intent(MainActivity.this, butt5Activity.class);
startActivity(int5);
}
});
button6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int6 = new Intent(MainActivity.this, butt6Activity.class);
startActivity(int6);
}
});
button7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int7 = new Intent(MainActivity.this, butt7Activity.class);
startActivity(int7);
}
});
button8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int8 = new Intent(MainActivity.this, butt8Activity.class);
startActivity(int8);
}
});
button9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int9 = new Intent(MainActivity.this, butt9Activity.class);
startActivity(int9);
}
});
button10.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int10 = new Intent(MainActivity.this, butt10Activity.class);
startActivity(int10);
}
});
button11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent int11 = new Intent(MainActivity.this, butt11Activity.class);
startActivity(int11);
}
});
}
public void Showpopup (View v) {
TextView txtofclose;
mydialog.setContentView(R.layout.activity_main2);
txtofclose = (TextView) mydialog.findViewById(R.id.txtofclose);
txtofclose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mydialog.dismiss();
}
});
mydialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
mydialog.show();
}
}
答案 0 :(得分:0)
有几种方法可以完成此任务,而我目前无法进行任务。