I want to add tv1 tv2.,,, multiple TextView, click on the TextView shows the corresponding picture Dialog
Public class Activity_2 extends the Activity {
Dialog dia.
Private TextView TV;
@ Override
Protected void onCreate (Bundle savedInstanceState) {
Super. OnCreate (savedInstanceState);
The setContentView (R.l ayout. Activity_2);
TV=(TextView) the findViewById (R.i which v);
TV. SetOnClickListener (new an OnClickListener () {
@ Override
Public void onClick (View View) {
Dia. The show ();
}
});
The Context Context=Activity_2. This;
Dia=new Dialog (context, R.s tyle. Edit_AlertDialog_style);
Dia. The setContentView (R.l ayout. Activity_2);
ImageView ImageView=(ImageView) dia. The findViewById (R.i d.i mageView);
ImageView. SetBackgroundResource (R.d rawable. Cpi);
//select true click other places you can make the dialog disappears, false words won't disappear
Dia. SetCanceledOnTouchOutside (true);//Sets been this dialog is
The Window w=dia. GetWindow ();
WindowManager. LayoutParams lp=w.g etAttributes ();
Lp. X=0;
Lp. Y=0;
Dia. OnWindowAttributesChanged (lp);
ImageView. SetOnClickListener (
New an OnClickListener () {
@ Override
Public void onClick (View View) {
Dia. Dismiss ();
}
});
}
}
CodePudding user response:
Are you want to give a TextView add multiple clickable state or just want to create multiple TextView, according to you to create the number of cycles to create?CodePudding user response:
The simplest method is toDialog dia.
Private TextView TV;
To an array of
Dialog dia [];
Private TextView TV [];
Code, is an array element dia and TV subscript subscript corresponds to