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));
版权声明:本文标题:中山大学android手机平台开发期末必备代码! 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/b/1713594422a642452.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论