admin 管理员组

文章数量: 1086019


2024年4月20日发(作者:汇编语言的原理)

实验3(Button程序设计)

(触发文字改变、循环改变图片、动态添加按钮)

public class Ex03Activity extends Activity {

private Button mBtn;

private TextView mTxt;

private ImageButton mImageBtn;

boolean flag=true;

private Button mBtn1;

private Context mContext;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

te(savedInstanceState);

setContentView();

mTxt = (TextView)findViewById(loWorld);

mBtn = (Button)findViewById(1);

OnClickListener Btn1_Listener = new OnClickListener()

{

};

lickListener(Btn1_Listener);

mImageBtn = (ImageButton)findViewById(tn2);

OnClickListener ImageBtn2_Listener = new OnClickListener()

{

};

lickListener(ImageBtn2_Listener);

mContext = this;

mBtn1=new Button(mContext);

t("动态添加按钮");

public void onClick(View v){

}

}

flag=true;

flag=false;

if(flag){

public void onClick(View v){

}

t("按下了"+f(((Button)v).getText()));

geDrawable(getResources().getDrawable(2));

}else{

geDrawable(getResources().getDrawable(1));

LinearLayout mLinearLatout=(LinearLayout)findViewById(i);

w(mBtn1);

OnClickListener mBtn1_Listener = new OnClickListener()

{

};

lickListener(mBtn1_Listener);

}

}

public void onClick(View v){

}

Toast toast = xt(mContext, "动态添加按钮", _LONG);

vity(_VERTICAL, 0, 0);

();

(输入帐号密码触发图像改变)

public class MainActivity extends Activity {

private ImageButton but1;

private Button but2;

private EditText user;

private EditText password;

private Context mContext;

private TextView text;

@Override

public void onCreate(Bundle savedInstanceState) {

te(savedInstanceState);

setContentView(ty_main);

mContext = this;

text=new TextView(mContext);

t("动态添加TextView");

LinearLayout mLinearLatout=(LinearLayout)findViewById();

w(text);

but1=(ImageButton)findViewById(utton1);

OnClickListener imageButton1_Listener = new OnClickListener(){

if((t().toString().equals("android"))&&(t().toString().equa

geDrawable(getResources().getDrawable(03state1));

public void onClick(View v){

user=(EditText)findViewById(xt1);

password=(EditText)findViewById(xt2);

ls("b403")))

else

geDrawable(getResources().getDrawable(03state2));


本文标签: 改变 动态 添加 触发 汇编语言