云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > android常用控件总结

android常用控件总结

  • 62 次阅读
  • 3 次下载
  • 2025/5/2 6:24:43

main.xml

android:id=\ android:layout_width=\ android:layout_height=\ android:text=\ />

android:id=\ android:layout_width=\ android:layout_height=\ android:orientation=\ android:layout_x=\ android:layout_y=\ >

android:id=\ android:layout_width=\ android:layout_height=\ android:text=\ />

android:id=\ android:layout_width=\ android:layout_height=\ android:text=\ />

android:id=\ android:layout_width=\ android:layout_height=\ android:text=\ />

android:id=\ android:layout_width=\ android:layout_height=\ android:text=\ />

public class Activity01 extends Activity{ TextView m_TextView; RadioGroup m_RadioGroup;

RadioButton m_Radio1, m_Radio2, m_Radio3, m_Radio4;

@Override

public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main);

m_RadioGroup = (RadioGroup) findViewById(R.id.RadioGroup01);//获得RadioGroup对象

m_Radio1 = (RadioButton) findViewById(R.id.RadioButton1);//获得4个RadioButton对象

m_Radio2 = (RadioButton) findViewById(R.id.RadioButton2); m_Radio3 = (RadioButton) findViewById(R.id.RadioButton3); m_Radio4 = (RadioButton) findViewById(R.id.RadioButton4);

/* 设置事件监听 */

m_RadioGroup.setOnCheckedChangeListener(new

RadioGroup.OnCheckedChangeListener() {---------------------------RadioGroup监听器

@Override

public void onCheckedChanged(RadioGroup group, int checkedId){

if (checkedId == m_Radio2.getId()){

DisplayToast(\正确答案:\+ m_Radio2.getText() + \,恭喜你,回答正确!\ }else{

DisplayToast(\请注意,回答错误!\ } } }); }

public void DisplayToast(String str)//显示Toast{

Toast toast = Toast.makeText(this, str, Toast.LENGTH_LONG); //设置toast显示的位置

toast.setGravity(Gravity.TOP, 0, 220); //显示该Toast toast.show(); } }

-----------------------------------------------------------------------------------------------------------

AutoCompletTextView 和MultiAutoCompleteTextView 作用:自动提示 下面例中用到了ArrayAdapter

autoCompletTextView.xml

android:id= \ android:layout_width=\ android:layout_height=\ />

android:id= \ android:layout_width=\ android:layout_height=\ />

//如何实现如果输入的字符不在其范围内的也能得到提示 是继承TextWatcher? public class Control_Auto extends Activity { //implements TextWatcher{} public TextView textView_auto;

private static final String[] string ={\hao\hao \hao ma\zheng de hao ma\

public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState);

setContentView(R.layout.autocompletetextview);

//将可选内容与适配器ArrayAdapter连接

搜索更多关于: android常用控件总结 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com